76.7k views
0 votes
Dr. Smith is teaching IT 103 and wants to determine the highest and average grade earned on her midtrm. In Dr. Smith's class, there can be a maximum of 35 students. Midtrm grades fall in the range of 0 to 100, inclusive of these values. Write a small program that will allow Dr. Smith to enter grades as long as she wants and then determine the average grade and the highest grade of the midtrm. The program should also print the name of the students who got the highest grade.

User Roseanne
by
8.4k points

1 Answer

2 votes

Final answer:

The question is about creating a Python program that can calculate both the highest and the average grades for a class, and list the students who achieved the highest grade.

Step-by-step explanation:

Python Program for Calculating Midterm Grades

Dr. Smith needs a program to calculate the highest and average grades for IT 103, and identify the students with the highest grade. Below is a simple Python script for this purpose:

students_grades = {}
highest_grade = 0

while True:
name = input("Enter student name (or 'stop' to finish): ")
if name == 'stop':
break
grade = float(input("Enter grade for " + name + ": "))
students_grades[name] = grade
if grade > highest_grade:
highest_grade = grade

average_grade = sum(students_grades.values()) / len(students_grades)
top_students = [name for name, grade in students_grades.items() if grade == highest_grade]

print("The highest grade is:", highest_grade)
print("The average grade is:", average_grade)
print("Students with the highest grade:", top_students)

This program prompts Dr. Smith to input student names and their grades continuously until 'stop' is entered. It calculates both the average and the highest grades, and stores the names of the students who achieved the highest grade, which are printed at the end.

User Ankii Rawat
by
7.3k points