Answered step by step
Verified Expert Solution
Question
1 Approved Answer
def total _ price ( fruit _ prices: dict, purchases ) - > float: ' ' ' Compute the fruit prices give the quantity of
def totalpricefruitprices: dict, purchases float:
Compute the fruit prices give the quantity of each fruit. Do not use the sum function.
Arguments:
fruitprices: dict fruit name as key and price as value
purchases: listtuple as list of tuples of fruit quantity
Return:
totalprice: float
def totalpricenoloopsfruitprices: dict, purchases float:
Compute the total price without loops.
def findcheapestfruitfruitprices:dict str:
Find the cheapest fruit from the fruitprices dict, do not use min function
Arguments:
fruitprices: dict fruit name as key and price as value
Return:
cheapestfruit: str the fruit with the lowest price
def findcheapestfruitnoloopsfruitprices:dict str:
Find the cheapest fruit using min function. Do not use loops
# grouping
def groupfruitsfruits:list:
Group the fruits based on the first letter of the names. Assume first letters will be upper case.
Arguments:
fruits list: list of fruit names
Return:
dict: dict with the first letters as keys and list of fruits sorted in ascending order as values.
# binning
def binfruitsfruitprices:
Classify the fruits as cheap, affordable and costly based on the fruit prices. Create a dictionary with the classification as keys and a set of fruits in that category.
cheap less than not inclusive
affordable between and both inclusive
costly greater than not inclusive
Arguments:
fruitprices: dict dictionary with fruits as keys and prices as values
Return:
binnedfruits: dict dictionary with category as key and a set of fruits in that category as values.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started