Skip to content
Programs · Program 10-1

Q.Program 10-1: This is a program to create a nested tuple to store roll number, name and marks of students

Telangana TsbieTextbookSubjective· 3mImportance★★★★★est
7% · 2/30 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Store each student as an inner (roll, name, marks) tuple inside one outer tuple, then loop with double indexing st[i][field] to print a tabulated report.

The idea. When every record has the same fixed structure and should stay read-only, a tuple of tuples is the natural container: the outer tuple is the register, each inner tuple is one student's record. Element access needs two indexes — the first selects the student, the second selects the field (0 roll number, 1 name, 2 marks).

Program 10-1:

# Program 10-1: nested tuple to store roll number, name and marks of students
st = ((101, "Aman", 98), (102, "Geet", 95), (103, "Sahil", 87), (104, "Pawan", 79))
print("S_No", "Roll_No", "Name", "Marks")
for i in range(0, len(st)):
    print((i + 1), '\t', st[i][0], '\t', st[i][1], '\t', st[i][2])

Verified output:

S_No Roll_No Name Marks
1   101   Aman   98
2   102   Geet   95
3   103   Sahil   87
4   104   Pawan   79

Key lines:

  • st[i] is the i-th student's whole record; st[i][0], st[i][1], st[i][2] are its roll number, name and marks. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.