HW: Input & Ifs

In this HW you will create 3 programs that explore getting user input and using if statements.

Rx: <15 min Av: 15-30 min Sd: 30-45 min DNF: 45+ min

temperature.py

Create a program that asks the user for the current temperature and outputs what they should wear. Your program should meet the following requirements:

  1. Has a variable, temp, that stores the temperature input from the user
  2. Requests the user to enter the temperature
  3. Displays the following information based on the temperature range:
    • Above 90: “Whoa, it’s boiling!”
    • Above or equal to 80: “It’s getting hot”
    • Below 80: “A perfect day”
    • Below 60: “Don’t forget your sweater”
    • Below freezing: “Brrr, you need a coat!”

Only one phrase should be displayed to the user for any given temperature input. Make sure to test your program with multiple temperatures.

absolute_value.py

Create a program that asks the user for a number and prints its absolute value without using any python functions (in other words, you should use an if statement).

is_multiple.py

Create a program that asks the user for a whole number and prints whether it’s a multiple of 5. Make sure to test the program by inputting numbers that are multiples of 5 as well as those that aren’t multiples of 5. (Hint: what arithmetic operator can you use to determine whether a number is a multiple of another?)