Computers and Technology

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']

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, JeroMii
Think about a recent customer service experience - either positive or negative. write a brief summary of that experience. now think about those four characteristics we look for in customer service representatives. how did the representative in your example stack up? write down your answer and give specific examples.
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, deflox74
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
image
Computers and Technology, 24.06.2019 01:00, arturocarmena10
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
image
Computers and Technology, 24.06.2019 10:00, wwwcarolynzouowficz
3. what do the terms multipotentialite, polymath, or scanner mean?
Answers: 2
Do you know the correct answer?
The last time we sorted apples we used two separate arrays (i. e. lists), one to hold the names, one...

Questions in other subjects:

Konu
Mathematics, 03.12.2020 06:10
Konu
Computers and Technology, 03.12.2020 06:10