python - Coding Exercise: Timbits-Fix the bugs and pass all of the tests -
i've been looking @ program while , can't seem find wrong code. i've checked numbers , fine. think quotes or parentheses. appreciate help. here's code:
# step 1: input timbitsleft = int(input()) # step 2: initialize total cost totalcost = 0 # step 3: buy many large boxes can bigboxes = int(timbitsleft / 40) totalcost = totalcost + bigboxes * 6.19 # update total price timbitsleft = timbitsleft - 40 * bigboxes # calculate timbits still needed # step 4, can buy medium box? if timbitsleft >= 20: totalcost = totalcost + 3.39 timbitsleft = timbitsleft - 20 if timbitsleft > 10: # step 5, can buy small box? totalcost = totalcost + 1.99 timbitsleft = timbitsleft - 20 # step 6 totalcost = totalcost + timbitsleft * 20 print(totalcost)
this error get: did not pass tests. please check details below , try again. results test case 1 out of 11
input: 10 program executed without crashing.
program output: 200.0
expected correct output: 1.99
result of grading: output line 1, value 200.0, did not match expected value 1.99
you getting output of 200 because not have enough money buy large box or medium box. check see if can buy small box, have 10 timbits, if statement, if timbitsleft > 10: # step 5, can buy small box?
, not true cannot buy small box either. calculation totalcost = totalcost + timbitsleft * 20
gives value of 200.
Comments
Post a Comment