Professional Documents
Culture Documents
k214548 AI Lab 2.ipynb - Colaboratory
k214548 AI Lab 2.ipynb - Colaboratory
ipynb - Colaboratory
def calculate_average(grades):
if grades:
return sum(grades) / len(grades)
else:
return 0
def display_student_dictionary(student_dictionary):
print("\n--- Overall Gradebook ---\n")
for std_name, grades in student_dictionary.items():
average_grade = calculate_average(grades)
print(f"Student Name - {std_name}:\nGrades - {grades},\nAverage - {average_grade:.2f}\n")
print("------------------------\n")
student_dictionary = {}
add_student(student_dictionary, "Haseeb")
add_grades(student_dictionary, "Haseeb", (90, 85, 92))
add_student(student_dictionary, "Sufyan")
add_grades(student_dictionary, "Sufyan", (88, 95, 91))
add_grades(student_dictionary, "Haseeb", (78, 80, 85))
display_student_dictionary(student_dictionary)
------------------------
https://colab.research.google.com/drive/140jYA9JPfizsXi-1jGQ_zGbRs1STCr1x#printMode=true 1/2