Exercise:
num = int(input("Please input how many students:"))
student = []
sum_score = 0
for i in range(num):
score = int(input("Please input score of student "+str(i+1)+":"))
sum_score += score
student.append(score)
for i in range(len(student)):
print(student[i])
print("Average score of the students: ",sum_score/num)
Homework:
num = int(input("Please input how many students:"))
student = []
for i in range(num):
score = int(input("Please input the score of student "+str(i+1) + ":"))
student.append(score)
student.sort(reverse = True)
for i in range(len(student)):
print("No.", (i+1),": ",student[i])
max_score = max(student)
min_score = min(student)
avg_score = sum(student)/num
print("Highest score: ",max_score,",Lowest score: ",min_score,",Average: ",avg_score)
[…] II| |____Unit 28 Perpetual Calendar I| |____Unit 29 Perpetual Calendar II|____Python Level 4| |____Unit 30 First Glance at List| |____Unit 31 More Operations on Lists| |____Unit 32 Common Algorithms for Lists| |____Unit 33 […]