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 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad