Machine Problem 1-1
Make a simple calculator using Python about temperature conversion.
DS100-1
3Q1920Info! Broken links? Email us at gtechphofficial@gmail.com
Code:
def CtoF(value):
F = value*(9/5)+32
return str(value) + "°C is " + str(F) + "°F"
def FtoC(value):
C = (value-32)*5/9
return str(value) + "°F is " + str(C) + "°C"
choice = input("1 - Celsius to Fahrenheit\n2 - Fahrenheit to Celsius\nChoose an option: ")
if int(choice) == 1:
value = input("Enter value in Celsius: ")
print(CtoF(float(value)))
elif int(choice) == 2:
value = input("Enter value in Fahreneheit: ")
print(FtoC(float(value)))