Reputation: 1
Using python program to find the average marks of all subject for all the following students:
Student ID | Quiz | Research Project | Assignment | Final Exam
1 | 40/50 | 50/100 | 15/20 | 50/100
2 | 50/50 | 30/100 | 10/20 | 10/100
3 | 22/50 | 43/100 | 8/20 | 30/100
4 | 40/50 | 36/100 | 19/20 | 43/100
5 | 20/50 | 80/100 | 11/20 | 51/100
Rules to follow:
The sample output should look exactly like that:
student 1 have 63.75 average.
student 2 have 47.50 average.
student 3 have 39.25 average.
student 4 have 63.50 average.
student 5 have 56.50 average.
I have tried to code it, below is my code:
markss = [[0.8, 0.5, 0.75, 0.5], [1, 0.3, 0.5, 0.1], [0.44, 0.43, 0.4,
0.3], [0.8, 0.8, 0.95, 0.43], [0.4, 0.8, 0.55, 0.51]]
average = [(sum(avg)/float(len(avg)))*100 for avg in markss]
print(f"student 1 have {average[0]:.2f} average.")
print(f"student 2 have {average[1]:.2f} average.")
print(f"student 3 have {average[2]:.2f} average.")
print(f"student 4 have {average[3]:.2f} average.")
print(f"student 5 have {average[4]:.2f} average.")
Upvotes: 0
Views: 71
Reputation: 54
my2dlist = [] # declare normal list
my2dlist.append([x for x in range(2)]) # adding lists
my2dlist.append([x for x in range(9)])
print(my2dlist)
print(my2dlist[0][1]) # accessing entry
Upvotes: 1