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]
3 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]3 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
PLEASE HELP SOMEONE!!!!!!!!! WILL GIVE BRAINLIEST!!!!!!!!!!!!!!!!!!!!!!!!! Fill in the blanks.
olasank [31]
<span> change the behavior of the program I think</span>
7 0
4 years ago
Which would increase electric current? increasing the resistance increasing the size of the wire decreasing the voltage
Neko [114]
The answer is the second answer Increasing the size of the wire.
8 0
3 years ago
At the aquarium Grandma Simpson hugged the dolphin is that passive or active sentence​?
geniusboy [140]

It is passive, because it says the grandma huggED the dolphin.

Active would be “Grandma Simpson hugs the dolphin at the aquarium.”

5 0
4 years ago
When engineers consider _____, they propose giving up a benefit of one proposed design in order to obtain a benefit of a differe
spin [16.1K]

Answer:

The answer is A. Constraint.

5 0
3 years ago
______ is where a media company uses its combined properties to promote each other and add value to the company.
Pie

<u>Synergy </u>is where a media company uses its combined properties to promote each other and add value to the company.  

<h3>What is known to be called Synergy?</h3>

Synergy is known to be a term that connote a form of an interaction or the kind of a cooperation that brings about  a state which  is greater than the simple sum of its parts.

The term synergy originate from the Attic Greek word that connote  "working together" and as such, <u>Synergy </u>is where a media company uses its combined properties to promote each other and add value to the company.  

Learn more about Synergy  from

brainly.com/question/13639757
#SPJ1

6 0
2 years ago
Other questions:
  • Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al
    14·1 answer
  • A stop sign is an example of?
    11·2 answers
  • What exactly is 'epsilon' in Python?
    10·1 answer
  • Where is permanent data in the computer stored? Whenever Jim starts his laptop, he sees some commands and numbers appearing on h
    6·1 answer
  • All of the following are qualities of certification programs except:
    8·2 answers
  • What is the target audience of an ad?
    11·1 answer
  • What are cell phones used for?
    8·2 answers
  • The amount of pressure a power source creates to move electrons. *
    9·1 answer
  • after confirming the removal of a virus from a computer, how should the technician ensure and verify the full functionality of t
    7·1 answer
  • Write and test a program that computes the area of a circle. This program should request a number representing a radius as input
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!