Answer to Question #264318 in Python for niki

Question #264318

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

 



1
Expert's answer
2021-11-11T07:30:09-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS