Use the Design recipe to write the function total_bill, which consumes an amount of data transferred (gigabytes) and a base rate and computes the total charge. The total_bill function should call the appropriate function from Part A as required. Include a docstring.
def bill_small(data,base):
return base
def bill_medium(data,base):
return base+(0.15*base)+0.07*(data-100)
def bill_large(data,base):
return 2.0*base
Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks
BOLD PART is the answer...rest is usage code.
def bill_small(data,base):
return base
def bill_medium(data,base):
return base+(0.15*base)+0.07*(data-100)
def bill_large(data,base):
return 2.0*base
def total_bill(data,base):
'''Takes data usage and base price.
Based on data usage returns total bill'''
if data<=100:
return bill_small(data,base)
elif data>100 and data<=1000:
return bill_medium(data,base)
else:
return bill_large(data,base)
assert total_bill(10,80) == 80
assert total_bill(10000,80) == 160
assert total_bill(500,80) == 120
Get Answers For Free
Most questions answered within 1 hours.