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