At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Connect with professionals ready to provide precise answers to your questions on our comprehensive Q&A platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A 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)
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.