Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def total _ price ( fruit _ prices: dict, purchases ) - > float: ' ' ' Compute the fruit prices give the quantity of

def total_price(fruit_prices: dict, purchases)-> float:
'''
Compute the fruit prices give the quantity of each fruit. Do not use the sum function.
Arguments:
fruit_prices: dict - fruit name as key and price as value
purchases: list[tuple]- as list of tuples of (fruit, quantity)
Return:
total_price: float
'''
...
def total_price_no_loops(fruit_prices: dict, purchases)-> float:
'''
Compute the total price without loops.
'''
...
def find_cheapest_fruit(fruit_prices:dict)-> str:
'''
Find the cheapest fruit from the fruit_prices dict, do not use min function
Arguments:
fruit_prices: dict - fruit name as key and price as value
Return:
cheapest_fruit: str - the fruit with the lowest price
'''
...
def find_cheapest_fruit_no_loops(fruit_prices:dict)-> str:
'''
Find the cheapest fruit using min function. Do not use loops
'''
...
# grouping
def group_fruits(fruits: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 bin_fruits(fruit_prices):
'''
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 3(not inclusive)
affordable - between 3 and 6(both inclusive)
costly - greater than 6(not inclusive)
Arguments:
fruit_prices: dict - dictionary with fruits as keys and prices as values
Return:
binned_fruits: 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Connect with your audience

Answered: 1 week ago