Skip to content

Use math and variables to convert temperatures between fahrenheit and celsius

Notifications You must be signed in to change notification settings

Justice-Through-Code/challenge-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Temperature Conversion

Challenge 1

Estimated Time to Complete

60 minutes


Learning Objectives

Start working with variables, math, and printing


Assignment Overview

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?

  1. Convert a temperature of 100 degrees fahrenheit to celsius
    • Save this to a variable called celsius_100, and use print() to print out the value
    • Is the resulting temperature you get an integer or float? How do you know?
  2. Convert a temperature of 0 degrees fahrenheit to celsius
    • Save this to a variable called celsius_0, and use print() to print out the value
  3. Convert a temperature of 34.2 degrees fahrenheit to celsius
    • Do this one all in one print statement without saving any variables

Now, can you convert back?

  1. Convert a temperature of 5 degrees celsius to fahrenheit
  2. 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.


Summary

  1. Accept the challenge via the GitHub Classroom link (if you're already here, you've done this part!)
  2. Clone the repo to your computer
  3. 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
  4. Run your computer's version of python3 -m unittest temp_conversion_test.py to see if your code works as expected
  5. 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!

About

Use math and variables to convert temperatures between fahrenheit and celsius

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages