A)Using python data structure to store marks scored in subject "Python Programming" by N students in the class. Write functions | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

A)Using python data structure to store marks scored in subject "Python Programming" by N students in the class. Write functions

16th Oct 2022, 5:09 PM
Yamini Gogineni
1 Answer
0
classroom = {} def add_student_marks(student_name, marks): classroom[student_name] = marks def get_student_marks(student_name): return classroom.get(student_name, "Student not found") def get_average_marks(): total_marks = sum(classroom.values()) return total_marks / len(classroom) if classroom else 0 def get_highest_marks(): if classroom: max_marks = max(classroom.values()) top_students = [student for student, marks in classroom.items() if marks == max_marks] return top_students, max_marks return "No students in the class", 0 # Example usage add_student_marks("Alice", 95) add_student_marks("Bob", 87) add_student_marks("Charlie", 92) print(get_student_marks("Alice")) print(get_average_marks()) print(get_highest_marks())
17th Aug 2023, 5:10 PM
Zahed Shaikh
Zahed Shaikh - avatar