Q. In the program created in previous question , add a function that computes total marks and average marks obtain by each student .
You can understand by Watching video :-
Answer :-
total = () for i in range(5): print("Enter Marks of Student no.", i+1 ) mark = () mark1 = int(input("Enter the marks of first subject = ")) mark2 = int(input("Enter the marks of second subject = ")) mark3 = int(input("Enter the marks of third subject = ")) print() print("Total marks of student no." ,i+1,":-", mark1 + mark2 + mark3) print("Average marks of student no." ,i+1,":-", (mark1 + mark2 + mark3 )/3) mark = (mark1 , mark2 , mark3) total= total + (mark,) print() print("Final Tuple= ",total)
Output :-
Enter Marks of Student no. 1
Enter the marks of first subject = 58
Enter the marks of second subject = 57
Enter the marks of third subject = 65
Total marks of student no. 1 :- 180
Average marks of student no. 1 :- 60.0
Enter Marks of Student no. 2
Enter the marks of first subject = 98
Enter the marks of second subject = 56
Enter the marks of third subject = 25
Total marks of student no. 2 :- 179
Average marks of student no. 2 :- 59.666666666666664
Enter Marks of Student no. 3
Enter the marks of first subject = 98
Enter the marks of second subject = 99
Enter the marks of third subject = 91
Total marks of student no. 3 :- 288
Average marks of student no. 3 :- 96.0
Enter Marks of Student no. 4
Enter the marks of first subject = 65
Enter the marks of second subject = 85
Enter the marks of third subject = 74
Total marks of student no. 4 :- 224
Average marks of student no. 4 :- 74.66666666666667
Enter Marks of Student no. 5
Enter the marks of first subject = 78
Enter the marks of second subject = 65
Enter the marks of third subject = 96
Total marks of student no. 5 :- 239
Average marks of student no. 5 :- 79.66666666666667
Final Tuple= ((58, 57, 65), (98, 56, 25), (98, 99, 91), (65, 85, 74), (78, 65, 96))
>>>
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )