Question

Use the Design recipe to write the function total_bill, which consumes an amount of data transferred...

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

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Use the Design Recipe to write a function count_evens_NxN,  that consumes a nested list representing a matrix...
Use the Design Recipe to write a function count_evens_NxN,  that consumes a nested list representing a matrix of size NxN. The function should return the number of even numbers in the matrix. For this function, 0 is considered an even number.  Include a Docstring! Note: You may assume the list argument passed to the function is a nested list of integers. Write 3 assert_equal statements to test your function.
Question Recursive Maximum: In this question you must develop and use a recurive function to find...
Question Recursive Maximum: In this question you must develop and use a recurive function to find the maximum value in array of integers. Complete the C program, Maximum.c, by implementing the recursive function maximumValue, and the regular function max, and completing the main function using the comments provided. Open the file Maximum.c, complete, compile and run it. When you are sure it is correct, include the c file in your final submission. Note that the function max is not recursive....
write C++ programs Array of Payroll Objects Design a PayRoll class that has data members for...
write C++ programs Array of Payroll Objects Design a PayRoll class that has data members for an employee’s hourly pay rate and number of hours worked. Write a program with an array of seven PayRoll objects. The program should read the number of hours each employee worked and their hourly pay rate from a file and call class functions to store this information in the appropriate objects. It should then call a class function, once for each object, to return...
Can you write the function in python? def remove_outliers(data, num_outliers): # When analyzing data collected as...
Can you write the function in python? def remove_outliers(data, num_outliers): # When analyzing data collected as a part of a science experiment it # may be desriable to remove the most extreme values before performing # other calculations. Complete this function which takes a list of # values and an non-negative integer, num_outliers, as its parameters. # The function should create a new copy of the list with the num_outliers # largest elements and the num_outliers smallest elements removed. #...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits from base class Account and include an additional data member of type double that represents the fee charged per transaction (transactionFee). Write Checking- Account’s constructor that receives the initial balance, as well as a parameter indicating a transaction fee amount. If transaction fee is less than zero, the transactionFee will be set to zero. Write the chargeFee member function that updates the balance by...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the...
Complete this in C++ and explain what is being done. 1      Introduction The functions in the following subsections can all go in one big file called pointerpractice.cpp. 1.1     Basics Write a function, int square 1(int∗ p), that takes a pointer to an int and returns the square of the int that it points to. Write a function, void square 2(int∗ p), that takes a pointer to an int and replaces that int (the one pointed to by p) with its...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class...
Suppose that the file inData.txt contains the following data: 3   4 5 15.6 “Mark” “Taylor” 28...
Suppose that the file inData.txt contains the following data: 3   4 5 15.6 “Mark” “Taylor” 28 18500 3.5 B The numbers in the first line represent the Side A, Side B and Side C of a Triangle. The number in the second line represents the radius of a circle (Assume that p = 3.1416). The third line contains the first name, last name, and the age of a person. The first number in the fourth line is the savings account...
SOME DRAWBACK OF BLACK-SCHOLES Briefly discuss here some difficulties associated with the Black Scholes formula, which...
SOME DRAWBACK OF BLACK-SCHOLES Briefly discuss here some difficulties associated with the Black Scholes formula, which is widely used to calculate the price of an option. For example, consider a European call option for a stock. This is the right to buy a specific number of shares of a specific stock on a specific date in the future, at a specific price (the exercise price, also called the strike price). If all these quantities are fixed, the question becomes: what...
The purposes of this article, capital assets are defined as tangible or intangible assets that are...
The purposes of this article, capital assets are defined as tangible or intangible assets that are used in operations and that have useful lives of more than one year, such as land and improvements to land, buildings and building improvements; vehicles; machinery; equipment; and sewer, water and highway infrastructures. Risk Assessment: A municipality’s capital assets are subject to a number of risks. Local officials must be cognizant of these risks as they seek to effectively manage their municipality’s capital assets....