subject

The last time we sorted apples we used two separate arrays (i. e. lists), one to hold the names, one to hold the 'sweetness' (called parallel arrays). Below is a single string that contains the same data:apples = "McIntosh:3,Red Delicious:5,Fuji:8,Gala:6,Ambrosia: 7,Honeycrisp:7.5,Granny Smith:1"In this case, the apples are separated by commas, and each apple has two attributes (name and sweetness) separated by a colon. We will use the power of string's split method to sort this dataset.1. define a function named apple_sort that takes a single string as an parameter, this string will be an "apple". That is it will be one of the items like 'Honeycrisp:7.5'. The function will return a numeric value that represents the sweetness of the item. This function will behave as a custom sorting function.2. define a function named a sort_csv that takes a single string as an parameter (which represents the complete dataset). This function will split the incoming dataset into the separate items and then it will sort those items using your function you created in part 1.So after you are done, the following code:print(sort_csv(apples))Should print out:['Fuji:8', 'Honeycrisp:7.5', 'Ambrosia:7', 'Gala:6', 'Red Delicious:5', 'McIntosh:3', 'Granny Smith:1']

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 14:10
In a flashdisk wich icon can you use to open files in computer
Answers: 1
question
Computers and Technology, 22.06.2019 22:00
What is a distinguishing feature of today’s graphic application software?) graphic applications are used today on a variety of devices, including touch-screen kiosks and mobile phones.
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
You know the right answer?
The last time we sorted apples we used two separate arrays (i. e. lists), one to hold the names, one...
Questions
question
Mathematics, 01.03.2021 16:30
Questions on the website: 13722361