Question: Coding Exercise: Age checker Write a program that reads an integer from input, representing someone's age. If the age is 18 or larger, print out

Coding Exercise: Age checker

Write a program that reads an integer from input, representing someone's age. If the age is 18 or larger, print out You can vote. If the age is between 0 and 17 inclusive, print out Too young to vote. If the age is less than 0, print out You are a time traveller. age = int(input())

Coding Exercise: Timbits

Fix the bugs and pass all of the tests!

timbitsLeft = int(input()) # step 1: get the input totalCost = 0 # step 2: initialize the total cost

# step 3: buy as many large boxes as you can bigBoxes = int(timbitsLeft / 40) totalCost = totalCost + bigBoxes * 6.19 # update the total price timbitsLeft = timbitsLeft - 40 * bigBoxes # calculate timbits still needed

if timbitsLeft >= 20: # step 4, can we buy a medium box? totalCost = totalCost + 3.39 timbitsLeft = timbitsLeft - 20 if timbitsLeft >= 10: # step 5, can we buy a small box? totalCost = totalCost + 1.99 timbitsLeft = timbitsLeft - 20

totalCost = totalCost + timbitsLeft * 20 # step 6 print(totalCost)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!