F2C / C2F converter
Convert Fahrenheit to Celciusor the other way around
with Python
Go to the menu-list
I still need to make a UI, so below the code in front (it works very well on my laptop)
# mathematical-formula F to C: C = (F - 32) x .5556
# mathematical-formula C to F: F = C * 1.8 + 32
# To do: layout... GUI?
def F2C():
run = 0
while run < 1:
Fahrenheit = input ("\r\nHow many degrees Fahrenheit (No decimals)?\r\n('q' to quit, start with '-' for negative value): ")
if Fahrenheit.isnumeric() == False:
if Fahrenheit == "q":
from sys import exit
exit()
elif Fahrenheit.startswith("-"):
Celcius = (int(Fahrenheit) - 32) * 0.5556
print("\nCelcius: " + str(Celcius))
else:
print("\nOnly numeric values")
else:
Celcius = (int(Fahrenheit) - 32) * 0.5556
print("\nCelcius: " + str(Celcius))
def C2F():
run = 0
while run < 1:
Celcius = input ("\r\nHow many degrees Celcius (No decimals)?\r\n('q' to quit, start with '-' for negative value): ")
if Celcius.isnumeric() == False:
if Celcius == "q":
from sys import exit
exit()
elif Celcius.startswith("-"):
Fahrenheit = (int(Celcius) * 1.8) + 32
print("\nFahrenheit: " + str(Fahrenheit))
else:
print("\nOnly numeric values")
else:
Fahrenheit = (int(Celcius) * 1.8) + 32
print("\nFahrenheit: " + str(Fahrenheit))
choice_run = 0
while choice_run < 1:
choice = input("Convert Celcius to Fahrenheit (c)\r\nor Fahrenheit to Celcius (f)\r\n?: ")
if choice == "c":
C2F()
elif choice == "f":
F2C()
else:
print("\nOnly c or f\n")