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'))

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