4.1 Write a program for each of the following:
(a) Listing all students whose CUM is K or higher. (Test the program using K = 3.00.)
(b) Listing all students in year L. (Test the program using L= 2, or sophomore.
last = ["Adams", "Bailey", "Cheng", "Davis", "Edwards", "Fox"]
cum = [2.55, 3.25, 3.40, 2.85, 1.75, 2.80]
years = [2, 4, 1, 1, 3, 2]
qualified = []
#Function checks whose CUM is equal or above K
def check_CUM(K):
for names in last:
if cum[last.index(names)] >= K:
qualified.append(names)
print(qualified)
check_CUM(3.00)
L_year_Students = []
#Function checks who is L year student
def check_student_year(L):
for name in last:
if years[last.index(name)] == L:
L_year_Students.append(name)
print(L_year_Students)
check_student_year(2)
Comments
Leave a comment