Programming Examples

Python program that interactively creates a nested tuple to store the marks in three subjects for five students


Write a program that interactively creates a nested tuple to store the marks in three subjects for five students.

i.e., tuple will look somewhat like: marks((45,45,40),(35,40,38),(36,30,38),(25,27,20),(10,15,20))

tup= ()
for a in range(1,6):
    print("Enter the Marks for student ",a)
    sub1= int(input("Enter Marks for Sub 1 : "))
    sub2= int(input("Enter Marks for Sub 2 : "))
    sub3= int(input("Enter Marks for Sub 3 : "))
    tup += ( (sub1,sub2,sub3 ),)
print(tup)

Output

Enter the Marks for student  1

Enter Marks for Sub 1 : 34

Enter Marks for Sub 2 : 23

Enter Marks for Sub 3 : 45

Enter the Marks for student  2

Enter Marks for Sub 1 : 56

Enter Marks for Sub 2 : 34

Enter Marks for Sub 3 : 45

Enter the Marks for student  3

Enter Marks for Sub 1 : 34

Enter Marks for Sub 2 : 56

Enter Marks for Sub 3 : 67

Enter the Marks for student  4

Enter Marks for Sub 1 : 34

Enter Marks for Sub 2 : 34

Enter Marks for Sub 3 : 45

Enter the Marks for student  5

Enter Marks for Sub 1 : 56

Enter Marks for Sub 2 : 67

Enter Marks for Sub 3 : 44

((34, 23, 45), (56, 34, 45), (34, 56, 67), (34, 34, 45), (56, 67, 44))

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz