Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10. An Internet service provider sets its base rate for data transfers in a give

ID: 3724603 • Letter: 1

Question

10. An Internet service provider sets its base rate for data transfers in a given month according to market conditions. Customers are billed for data transferred in a given month as follows:

Transfers up to and including 100 Gigabytes (GB) are charged this base rate per Gigabyte only.

Transfers over 100 GB up to and including 1000 GB are charged the base, plus an additional 15% of the base, plus an additional $0.07 per GB for each GB over 100GB.

Transfers above 1000 GB are charged simply twice the base per Gigabyte.

In your lab3.py file use BASE_RATE as a global constant to store the base rate price. Use the Design recipe to write the function, bill_amount(), which takes an amount of data transferred (gigabytes) and computes the total charge.

Write three "helper" functions (bill_small, bill_medium, bill_large) which each likewise take an amount of data, then calculates the charge according to the above schemes. E.g., bill_medium will expect a number between 101 and 1000, and return the base+(15% of base)+$0.07X(GB over 100).

The bill_amount function should call the appropriate helper as required. Bills should be rounded to the nearest cent.

PYTHON LANGUAGE

Explanation / Answer

BASE_RATE = 10.0   # The base rate in dollars.

# Helper functions to calculate the bill
def bill_small(data):
    return BASE_RATE * data

def bill_medium(data):
    return (BASE_RATE + 0.15 * BASE_RATE) * data + 0.07 * (data - 100)

def bill_large(data):
    return 2 * BASE_RATE * data

# funtions which calculates the bill depending on the amount of data transferred
def bill_amount(data):
    bill_amt = 0
    if data <= 100:
        bill_amt = bill_small(data)
    elif data <= 1000:
        bill_amt = bill_medium(data)
    else:
        bill_amt = bill_large(data)
    return round(bill_amt, 2) # Rounding off to nearest cent

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote