Apr 18, 2022 Uncategorized

Celsius to Fahrenheit and Vice Versa Python Project


Here are the formulas for converting F to C and  C to F:

T(°F) = T(°C) × 1.8 + 32  (Farenheit = Celsius * 1.8 + 32)

T(°C) = (T(°F) – 32) / 1.8 (Celsius = (Farenheit – 32) / 1.8)

Note: 1.8 = 9/5

Create an algorithm that does the following:

Display the following menu to the user:

Enter your selected option:

  • Convert Celsius to Farenheit

Convert Farenheit to Celsius

End Program

Use an if-statement to determine which value to get from the user, and which formula to use.

  1. Create a function for CelsiusToFarenheit and another function for FarenheitToCelsius
  2. Call the appropriate function according to the user’s selection.
  3. From each of the functions, ask the user for the temperature, and then display the converted temperature.

*If you CAN NOT install the Python Software for security reasons, choose one of the online compilers below.  Type in the code and click Run or Execute to see your results.

Note: using “raw_input” might not work with some Online compiles, please use “input” instead of raw_input.

Python Programs must include the following documentation at the top of the program (use comment lines):
Student’s full name and Period #
Date of assignment
Description of program

What to submit:

If you downloaded Python 2.7, submit your python program file with extension *.py (EX: convert.py).

If you were not able to install Python 2.7, submit a print screen image of your online compiler program code after you run it.

Resource Videos on converting temperatures using python

https://www.youtube.com/watch?v=z-0CmOQAD2k&t=92s  (Links to an external site.)

(This video only shows how to convert from Celsius to Fahrenheit, you must also convert Fahrenheit to celsius)

https://www.youtube.com/watch?v=5T6-9wEBAmY (Links to an external site.) Tags: computer sciencepython programmingCelsius to Fahrenheit