Display all grades:
No Grade
1 50.5
2 90.0
3 70.8
Average grade: 70.4
このように表示させたいんですけど、なかなかうまくいきません。自分が書いたコード貼って置くので解決策を教えていただきたいです。よろしくおねがいします!
score = []
#asking from the user for the number of grades
student_number = int(input('How many great to be enter: '))
while student_number < 1:
print('Invalid. Must be greater than 1. Try again.')
number = int(input('How many great to be enter: '))
#The user entered grades stored in a list
for i in range(student_number):
grade = float(input('Please enter the grade: '))
#displays all values in the grade list in a tabular format
print('Display all grades: ' + '\n' + 'No grate' + '\n' + '-' * 20)
template = '{0:<10} {1:<10}'
print(template.format(student_number, grade))
#Calculate and display the average grade
score = []
for k in score:
total_score = k[0] * k[1]
average = total_score/len(student_number)
print('Average grade: ' + str(average))
回答1件
あなたの回答
tips
プレビュー