#565 · Python Basics · Beginner · 35 XP · about 6 min
A power company charges for electricity by the unit, and a unit gets more expensive as a home uses more of them:
Write electricity_bill(units) that returns the bill in cents.
electricity_bill(80) # returns 400 electricity_bill(150) # returns 900 electricity_bill(250) # returns 1900
For 150 units, the first 100 cost 100 * 5 = 500 cents and the other 50 cost 50 * 8 = 400 cents, so the bill is 900 cents. Only the units above 100 pay the higher price.
units is a whole number, 0 or more.
First solves only, ranked by stars and then time.