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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started