60 minutes
Start working with variables, math, and printing
The formula for converting between fahrenheit and celsius is to first subtract 32, then multiply by 5/9. Can you do the following in python?
- Convert a temperature of 100 degrees fahrenheit to celsius
- Save this to a variable called
celsius_100
, and useprint()
to print out the value - Is the resulting temperature you get an integer or float? How do you know?
- Save this to a variable called
- Convert a temperature of 0 degrees fahrenheit to celsius
- Save this to a variable called
celsius_0
, and useprint()
to print out the value
- Save this to a variable called
- Convert a temperature of 34.2 degrees fahrenheit to celsius
- Do this one all in one print statement without saving any variables
- Convert a temperature of 5 degrees celsius to fahrenheit
- What is hotter, a temperature of 30.2 degrees celsius, or a temperature of 85.1 degrees fahrenheit?
Follow these instructions in temp_conversion.py
to convert temperatures between celsius and fahrenheit, then print them out.
- Accept the challenge via the GitHub Classroom link (if you're already here, you've done this part!)
- Clone the repo to your computer
- Follow the instructions in
temp_conversion.py
(the only.py
file that is not a_test.py
file)- Make sure to run your code often to see what changes you're making, with your computer's version of
python3 temp_conversion.py
in your terminal
- Make sure to run your code often to see what changes you're making, with your computer's version of
- Run your computer's version of
python3 -m unittest temp_conversion_test.py
to see if your code works as expected git add
,git commit
,git push
your code, and look for the little green check mark on your repo that tells you your tests passed
And you're all set!