Exercise:
number = int(input("Please input how many students:"))
score_list = []
for i in range(number):
score = int(input("Please input score of the student "+str(i+1)+":"))
score_list.append(score)
scores_greater_equal_60=[]
scores_less_60=[]
for i in score_list:
if i >= 60:
scores_greater_equal_60.append(i)
else:
scores_less_60.append(i)
print("Scores less than 60:", scores_less_60)
print("Scores greater than or equal 60:",scores_greater_equal_60)
Homework:
number = int(input("Please input how many students:"))
name_list = []
for i in range(number):
name = input("Please input name of the student "+str(i+1)+":")
name_list.append(name)
while True:
name = input("Please input student name you are looking for(Q/q to quit):")
if name == "Q" or name == "q":
print("Abort system.")
break
elif name in name_list:
print("The No. of " + name + " is: ",name_list.index(name))
else:
print(name," does not exist.")
[…] 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 Bubble Sort and Selection Sort| |____Unit […]