Flowchart to Python Code – Temperature Converter

Fahrenheit-CelsiusDegree Fahrenheit (°F) and Degree Celsius (°C) are the main two units to measure temperature.

The Fahrenheit scale is used mainly in the USA whereas other countries tend to use the Celsius scale.

It is possible to convert a temperature from Celsius degrees to Fahrenheit and vice-versa using the following conversion formulas:
fahrenheit_to_celsius_formulas

Your Challenge


Use the following flowchart to write a Temperature Converter in Python. Your script will:

  • Ask the end-user whether they want to convert from Celsius to Fahrenheit or from Fahrenheit to Celsius,
  • Ask the user to enter a temperature in the correct unit,
  • Apply the conversion formula and display the temperature in the new unit.

flowchart-temperature-conversion

Python Code


This algorithm is a good example of:
selection-label

Testing


Once your code is done, complete the following tests to check that your code is working as expected:

Test # Input Values Expected Output Actual Output
#1 Option 1
10°C
50°F
#2 Option 1
0°C
32°F
#3 Option 1
-5°C
23°F
#4 Option 2
50°F
10°C
#5 Option 2
32°F
0°C
#6 Option 2
23°F
-5°C
#4 Option x Invalid option!
unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 16

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: