Q. Write a program that interactively create a nested tuple to store the marks in three subjects for five 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()
    mark = (mark1 , mark2 , mark3)
    total= total + (mark,)
print("Final Tuple= ",total)

Output :-

Enter Marks of Student no. 1
Enter the marks of first subject = 95
Enter the marks of second subject = 86
Enter the marks of third subject = 42

Enter Marks of Student no. 2
Enter the marks of first subject = 64
Enter the marks of second subject = 29
Enter the marks of third subject = 34

Enter Marks of Student no. 3
Enter the marks of first subject = 85
Enter the marks of second subject = 97
Enter the marks of third subject = 45

Enter Marks of Student no. 4
Enter the marks of first subject = 23
Enter the marks of second subject = 45
Enter the marks of third subject = 13

Enter Marks of Student no. 5
Enter the marks of first subject = 96
Enter the marks of second subject = 58
Enter the marks of third subject = 94

Final Tuple=  ((95, 86, 42), (64, 29, 34), (85, 97, 45), (23, 45, 13), (96, 58, 94))

>>>


2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post