KnowledgeBoat Logo

Computer Science

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

Python

Python Tuples

23 Likes

Answer

tup = ()

while True :
      roll_num = int(input("Enter the roll number of student: "))
      name = input("Enter the name of student: ")
      marks = int(input("Enter the marks of student: "))
      tup += ((roll_num, name, marks),)
      choice = input("\nDo you want enter more marks? \n(Y/N) ")
      if (choice.lower() == 'n' or choice.lower() == 'no' ):
            print(tup)
            break

Output

Enter the name of student: Amit
Enter the marks of student: 45

Do you want enter more marks?
(Y/N) y
Enter the roll number of student: 23
Enter the name of student: Mahesh
Enter the marks of student: 99

Do you want enter more marks?
(Y/N) N
((12, 'Amit', 45), (23, 'Mahesh', 99))

Answered By

8 Likes


Related Questions