Pyhton Question: How do I go about printing the students grade after entering in
ID: 665004 • Letter: P
Question
Pyhton Question:
How do I go about printing the students grade after entering in grades?
def print_menu():
print('1. Add/modify student grade. ')
print('2. Delete student grade ')
print('3. Print student grades ')
print('4. Display the course statistics ')
print('5. Quit ')
print_menu()
menu_choice = 0
grades = {}
def add_or_mod():
name_points = str(input('Enter name and points: '))
nameGrade_list = name_points.split()
name = nameGrade_list[0]
points = nameGrade_list[1]
grades[name] = points
def removal():
removal=str(input(('Enter a name to be removed: ')))
del dict[removal]
def print_students_grade():
while menu_choice !=5:
menu_choice = str(input('Your choice: '))
if menu_choice == "1":
add_or_mod()
elif menu_choice == "2":
removal()
elif menu_choice == "3":
print_students_grade()
Explanation / Answer
_list = []
def calc_average(total):
return total / 5
def determine_grade(grade):
if grade >= 90 and grade <= 100:
return 'A'
elif grade >= 80 and grade <= 89:
return 'B'
elif grade >= 70 and grade <= 79:
return 'C'
elif grade >= 60 and grade <= 69:
return 'D'
else:
return 'F'
while True:
grade = int(input('Enter Marks: '))
_list.append(grade)
avg = calc_average(sum(_list))
abc_grade = ' '.join([determine_grade(mark) for mark in _list])
if len(_list) > 5:
break
print('Average grade is: ', avg)
print('Letter grades for entered grades are: ', abc_grade)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.