Programming Examples

Python program to create a nested tuple to store roll number name and marks of students


write a program to create a nested tuple to store roll number, name and marks of students.

Solution

tup= ()
while True :
      roll = int(input("Enter a roll number : "))
      name = input("Enter name :")
      mark = input("Enter marks :")
      tup += ( (roll,name,mark ),)
      flag = input("Do you want add another record (if yes the pres Y ) :")
      if flag not in ['y','Y']:
            break
print(tup)
Output

Enter a roll number : 101

Enter name :sam

Enter marks :567

Do you want add another record (if yes the pres Y ) :y

Enter a roll number : 102

Enter name :zaq

Enter marks :400

Do you want add another record (if yes the pres Y ) :n

((101, 'sam', '567'), (102, 'zaq', '400'))

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 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 Best Website and Software Company in Allahabad