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
Write a program that receives a Fibonacci term and returns a number telling which term it is. For instance, if you pass 3, it returns 5, telling it is 5th term; for 8, it returns 7.
Write a program to input n numbers from the user. Store these numbers in a tuple. Print the maximum and minimum number from this tuple.
Write a program that interactively creates a nested tuple to store the marks in three subjects for five students, i.e., tuple will look somewhat like :
marks( (45, 45, 40), (35, 40, 38), (36, 30, 38), (25, 27, 20), (10, 15, 20) )Write a program that interactively creates a nested tuple to store the marks in three subjects for five students and also add a function that computes total marks and average marks obtained by each student.
Tuple will look somewhat like :
marks( (45, 45, 40), (35, 40, 38),(36, 30, 38), (25, 27, 20), (10, 15, 20) )