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/ Explanation:

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

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad