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, 22.06.2019 20:00
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
question
Computers and Technology, 23.06.2019 20:40
On nba 2k 19, every time i try to join a my park game, it leads ro a website telling my dad that he needs ps plus. i already have ps plus though. how do i fix this?
Answers: 2
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
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
English, 10.10.2019 18:30
Questions on the website: 13722360