Program that will accept number of students and number of quizzes of students. Program will accept the name of the student and the quiz grades of the student. The input will be stored to a dictionary. The name of the student will be the key and the quizzes will be the value in list format (e.g., {“Jose S. Uy”: [87,90,97,80,95], “Rowena M. Evangelista”: [88,87,90,97,83].
The program will output the list of quizzes per student, the lowest quiz, the highest quiz, and the average quiz grade.
EXAMPLE:
number of students: 2
number of quizzes: 5
student 1: Jose S. Uy
quiz 1: 87
quiz 2: 90
quiz 3: 97
quiz 4: 80
quiz 5: 95
student 2: Rowena M. Evangelista
quiz 1: 88
quiz 2: 87
quiz 3: 90
quiz 4: 97
quiz 5: 83
Quiz Result:
Student 1: Jose S. Uy
Quizzes: [87, 90, 97, 80, 95]
Lowest: 80
Highest: 97
Average: 89.8
Student 2: Rowena M. Evangelista
Quizzes: [88, 87, 90, 97, 83]
Lowest: 83
Highest: 97
Average: 89
n_student = int(input("number of students: "))
n_quiz = int(input("number of quizzes: "))
print("")
stored_data = {}
for i in range(n_student):
name = input(f"student {i+1}: ")
stored_data[name] = []
for j in range(n_quiz):
stored_data[name].append(int(input(f"quiz {j+1}: ")))
print("")
print("\nQuiz Result:\n")
i = 1
for student in stored_data:
print(f"Student {i}:", student)
print("Quizzes:", stored_data[student])
low = min(stored_data[student])
hight = max(stored_data[student])
if len(stored_data[student]) > 0:
avr = sum(stored_data[student])/len(stored_data[student])
else:
avr = 0
print("Lowest:", low)
print("Highest:", hight)
print("Average", avr)
print("")
i += 1
Comments
Leave a comment