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
The designers of a database typically begin by developing a​ __________ to construct a logical representation of the database be
Pavlova-9 [17]

The designers of a database typically begin by developing a​ Data model to construct a logical representation of the database before it is implemented.

What is a data model?

A data model  in database is a type of data model that determines the logical structure of a database. It fundamentally determines in which manner data can be stored, organized and manipulated. They are three primary data models namely: relational, dimensional, and entity-relationship (E-R).

Learn more on Database model from:

brainly.com/question/17081023?referrer=searchResults

#SPJ4

8 0
1 year ago
Are you allowed to copy and paste answers on brainy to give answers to other people?
Zanzabum
I’m pretty sure you can; or u can also screenshot n send, which is what i usually doooo
7 0
3 years ago
Read 2 more answers
Dev10 is an Active Directory Domain Services (AD DS) domain member that runs Windows 10 Enterprise.
zubka84 [21]
Do I suppose to answer a question please let me know
8 0
3 years ago
Remi always works on several projects at a time. He has thousands of files saved on his computer. Yet he always seems to be able
astraxan [27]

Answer

the micmethod <-----made by myself

Explanation:

1. alphabetical order

2.put in empty folder

3.name folder after file put file in hard drive

4.a hard drive is also a usb

5.make hard drive into necklace and wear all the time

6. now u never lose it

4 0
3 years ago
Suppose Pentax develops a new photo editing software and negotiates agreements with a Vietnamese manufacturer to assemble most P
Elis [28]

Answer:

Contract manufacturing

Explanation:

Contract manufacturing involves outsourcing a portion of a manufacturing process of a product to another company.

5 0
3 years ago
Other questions:
  • You work for a large enterprise company that handles time-sensitive information. Your supervisor has asked that you set up a con
    8·1 answer
  • "what are the problems with tcp over wireless network?"
    15·1 answer
  • Write a function chat accepts a pointer to a C-string as its argument. The function should count the number of vowels appearing
    5·1 answer
  • How often does colleges update the cost of attendance on their website?.
    13·1 answer
  • 4.17 LAB: Varied amount of input data ( C++)
    5·1 answer
  • In the view that follows, which field can't be updated create view example_2 as select invoice_number, invoice_date, invoice_tot
    13·1 answer
  • Consider a system consisting of m resources of the same type, being shared by n processes. Resources can be requested and releas
    13·1 answer
  • What is collaboration
    14·1 answer
  • List all the steps used to search for 25 in the sequence given below. Use both (a) linear search and (b) binary search. 2, 7, 13
    7·1 answer
  • Goals of the project objectives
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!