1. Nice to meet you!
Predict the output of the following program and then run it to check your prediction.
2. Who are you?
In the program above, replace the first line of code with name = input("What is your name?") and then run the program to see what happens!
3. Your turn.
Using the editor below, create and run a program in which the user is prompted to enter the day of the week and the output states that the inputted day is a great day to do math! The name of the inputted day should appear in the outputted statement.
4. The heart of the matter.
The following program calculates and displays a person’s maximum heart rate based on their age. Examine and run the program to gain an understanding of how it works.
5. You're just not my type.
Let’s modify the heart rate program above so that it prompts the user to enter their age. Start by replacing the second line with age = input("What is your age?") and then run the program. Uh oh… there’s a problem! The issue is related to the fact that variables can store many different data types and only certain operations can be performed on a given data type. Click the following button for a brief summary of the data types that are most important for our work at this point.
6. An integral adjustment.
Now that you know something about data types, revisit the heart rate program above and replace the second line with age = int(input("What is your age?")). What do you think int() does? Why do you think it’s needed? Does the program work if the user inputs an integer value for their age? Try it!
7. Get to the (floating) point, please.
Can you edit the heart rate program above such that the user can input a decimal number? Give it a shot!
HINT: Click the Data Types button above!
8. Your turn.
Write and test a program that prompts the user to enter the base and height values of a triangle (in centimetres) and then calculates and displays the triangle’s area. Be sure to
- allow the user to enter numbers that have a decimal point.
- display the computed area rounded to one decimal place and include the unit of measurement (square centimetres).