In this lab, you'll write a program that takes input from the user, performs a computation, and then displays the results.
Exercise 1: Run this line of code and think about what it is doing
fav_color = input("What is your favorite color? ")
Exercise 2: Let's say we want to ask the user what their favorite number is. Each of the three lines might work. Which do you think is the most appropriate?
fav_number = input("What is your favorite number? ")
fav_number = int( input("What is your favorite number? ") )
fav_number = float( input("What is your favorite number? ") )
Exercise 3: The following code will run, but it probably won't give the result that the programmer was hoping for. Go ahead and run it.
first_number = input("What is your favorite number? ")
second_number = input("What is your second favorite number? ")
total = first_number + second_number
print("The sum of your two favorite numbers is",total)
In Thonny, you probably want to write this as a script, save it as a .py file, and then run it. The steps for doing this are as follows:
SyntaxError or TypeError, it's called a logic error.Challenge Exercise 4: Write a program that asks the user to enter their hourly wage and their number of hours worked, and then display their total pay for that pay period. This is what it should look like:
When you are finished, upload your .py file to the codePost Lab 3: Pay Calculator assignment. For this assignment, codePost will automatically test your code on several different inputs and check for the correct results, so make sure you test your program with additional test cases to ensure it is working.