Python 7 Levels, L4, Unit 30, First Glance at List

Powered By EmbedPress

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)

dahan1999

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts