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

USING PYTHON 2 An Internet service provider charges a base rate per megabyte (MB

ID: 3726500 • Letter: U

Question

USING PYTHON 2

An Internet service provider charges a base rate per megabyte (MB) transferred depending on market conditions. In addition to the base, transfers between 100 and 500 MB are charged an additional $0.05/MB plus 33% of the base. Data transfers between 500 MB and 1500 MB are charged 1.44 times the base plus $0.08/MB. Above 1500 MB the rate is simply twice the base. All data in a transfer is charged the same rate. For example, if 1600 MB are transfered, then the charge for all 1600 MB is twice the base. Develop the function 'bill_amount', which takes an amount of data transferred in megabytes and a base rate in dollars and computes the total charge.

def bill_amount(dataamount,baserte):

                  #do something…

                  return totalcharge

Explanation / Answer

For the given total bil charge   the code is in the following lines:

SOURCE CODE:

;;charge : Number Number -> Number
;; - given MB data transfer and the base base, compute chargess
(define (charge data base)
(cond
   [(<= data 100) (* data base)]
   [(and (> data 100) (<= data 500))
    (* (+ (* base 1.33) .05) data)]
   [(and (> data 500) (<= data 1500))
    (* (+ (* base 1.44) .08) data)]
   [(> data 1500)
    (* (* base 2) data)]))

(charge 100 1)
"should be" 100
(charge 501 1)
"should be" 761.52
(charge 1501 1)
"should be" 3002