Applied Programming/Variables/Python3
Appearance
variables.py
[edit | edit source]"""This program converts a Fahrenheit temperature to Celsius.
Input:
Fahrenheit temperature
Output:
Fahrenheit temperature
Celsius temperature
Example:
Enter Fahrenheit temperature:
100
100.0° Fahrenheit is 37.8° Celsius
TODO:
* All statements are currently global.
* Functions will be added in a future release.
References:
* http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
* http://www.mathsisfun.com/temperature-conversion.html
"""
TEMPERATURE_DIFFERENCE = 32
TEMPERATURE_RATIO = 5 / 9
print("Enter Fahrenheit temperature:")
fahrenheit = float(input())
celsius = (fahrenheit - TEMPERATURE_DIFFERENCE) * TEMPERATURE_RATIO
print(f'{fahrenheit:.1f}° Fahrenheit is {celsius:.1f}° Celsius')
Try It
[edit | edit source]Copy and paste the code above into one of the following free online development environments or use your own Python3 compiler / interpreter / IDE.
- GDB Online
- Ideone
- InterviewBit
- paiza.IO
- Programiz
- PythonTutor
- Python Fiddle
- repl.it
- RexTester
- Trinket
- TutorialsPoint
- Python Online
- Python Playground
- LabEx
- Python-Fiddle
- Python Sandbox