Question: Python #4 - Fix the code so it will calculate how much you should get paid, # even if someone enters a string of text...

Python

#4 - Fix the code so it will calculate how much you should get paid, # even if someone enters a string of text... Hint: Use try/except :)

#### add code here hours_work = float(input("How many hours do you work? ")) pay_rate = float(input("How much do you earn per hour? ")) print("You get paid:", hours_work*pay_rate) ####

#### add code here too print("That wasn't a number!! TRY AGAIN!") ####

Debug time! This program should check if the year is a leap year... # It's not working... Please fix it! # Hint: there are TWO changes... don't change the if statement

year = input("Input a year to check how many days are in February")

try: if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0: #based on https://www.timeanddate.com/date/leapyear.html print("There are 29 days in February in the year", year) else: print("There are 28 days in February in the year", year) accept: print("Incorrect input. Please enter a numeric year.")

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!