1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ronch [10]
2 years ago
6

Write a program to sort the (name, age, score) tuples by descending order where name is string, age and score are numbers. The s

ort criteria is: 1: Sort based on name 2: Then sort based on age 3: Then sort by score The priority is that name < age < score. If the following tuples are given as input to the program: [('John', '20', '91'), ('Jason', '21', '85'), ('Jony', '17', '91'), ('Johny', '17', '93'), ('Tom', '19', '80')]\
Computers and Technology
1 answer:
zimovet [89]2 years ago
6 0

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)

You might be interested in
When creating a report,you can mske groups and subgroups by?​
Mnenie [13.5K]

Answer:

content of the report

Explanation:

  • you must clarify all things
  • the report would be clean and clear
7 0
2 years ago
What are the five types of alignment in word?
valentinak56 [21]
I know of four,
Left-aligned
Center-aligned
right-aligned
justified

5 0
3 years ago
Read 2 more answers
How does the speaker feel about traditional forms of poetry
Salsk061 [2.6K]
A speaker sometimes is not able to capture the intended details since it is affected by homophones.
7 0
3 years ago
Read 2 more answers
What is printed when the following code has been executed?
serg [7]
Hey it is 15 hope this helps
3 0
2 years ago
The open items on your computer are displayed here. menu bar open bar taskbar toolbar
Dennis_Churaev [7]
Maybe the answer is the Taskbar?
8 0
3 years ago
Read 2 more answers
Other questions:
  • Pointsyour company environment includes windows server versions 2003, 2008, and 2012. desktops range from windows xp and vista.
    13·1 answer
  • The answer for this question?
    14·1 answer
  • Slicing can best be described as
    9·1 answer
  • Cloud resources are​ ________ because many different organizations use the same physical hardware.
    12·1 answer
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • Which model allows you to make subsystems in parallel?
    12·1 answer
  • What happens when you apply a theme to a form?
    14·1 answer
  • The wildcard character * (asterisk/start) and ? (question mark) are the same and can be use interchangeably.
    6·1 answer
  • The page that appears when you first open your Internet browser is the _____.
    8·1 answer
  • Integrity! He talks to me of integrity! I described a circle in the air. I'd tried to build my integrity upon the role of Brothe
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!