id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

gaurav1780@gmail.com 03_loops > toll
prev  |  next  |  chance

Transport NSW is trialling a new system for highway toll. You need to pay $1 up to the first 10 kms, and after that the the toll adds 1 for every 10kms or part of. Thus, if you travel 32kms, its $1 for the first 10, another $2 for the second 10, another $3 for the third 10, and another $4 for the last km (even though you didn't use the full 10kms). Define a function that when passed the distance travelled in kms, returns the applicable toll. Mathematically, this can be done without using loops too.


toll(31) → 10
toll(49) → 15
toll(505) → 1326

...Save, Compile, Run (ctrl-enter)

def toll(kms):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 2 Post-solution available

Copyright Nick Parlante 2017 - privacy