Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
The program in Python is as follows:
from operator import itemgetter
m = int(input("Number of records: "))
print("Name, Age, Score")
my_list =[]
for i in range(m):
user_details = input()
my_list.append(tuple((user_details.split(","))))
my_list.sort(key = itemgetter(0, 1, 2))
print("Sorted: ", my_list)
Explanation:
This imports the operator function from itemgetter
from operator import itemgetter
This gets the number of records, m
m = int(input("Number of records: "))
This prints the format of input
print("Name, Age, Score")
This initializes the list of tuples
my_list =[]
This iterates through m
for i in range(m):
This gets the details of each person
user_details = input()
This appends the details to the tuple
my_list.append(tuple((user_details.split(","))))
This sorts the tuple
my_list.sort(key = itemgetter(0, 1, 2))
This prints the sorted tuple
print("Sorted: ", my_list)
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.