If the user gave input like 90C and it should ignore the C
option=input("Please enter the convertion type: \n1.Celsius to Fahrenheit \n2.Fahrenheit to Celsius\n")
if option=="1":
Celsius=float(input("enter temperature in Celsius:"))
Fahrenheit=(Celsius*(9/5))+32
print("{0}°C is {1} in Fahrenheit".format(Celsius,Fahrenheit))
else:
Fahrenheit=float(input("please enter the temperature in Fahrenheit: "))
Celsius=(Fahrenheit-32)*(5/9)
print("{0}F is {1} in Celsius".format(Fahrenheit,Celsius))
If the user gave input like 90C and it should ignore the C
option=input("Please enter the convertion type: \n1.Celsius to Fahrenheit \n2.Fahrenheit to Celsius\n")
if option=="1":
Celsius=float(input("enter temperature in Celsius:"))
Fahrenheit=(Celsius*(9/5))+32
print("{0}°C is {1} in Fahrenheit".format(Celsius,Fahrenheit))
else:
Fahrenheit=float(input("please enter the temperature in Fahrenheit: "))
Celsius=(Fahrenheit-32)*(5/9)
print("{0}F is {1} in Celsius".format(Fahrenheit,Celsius))
If the user gave input like 90C and it should ignore the C
option=input("Please enter the convertion type: \n1.Celsius to Fahrenheit \n2.Fahrenheit to Celsius\n")
if option=="1":
Celsius=float(input("enter temperature in Celsius:"))
Fahrenheit=(Celsius*(9/5))+32
print("{0}°C is {1} in Fahrenheit".format(Celsius,Fahrenheit))
else:
Fahrenheit=float(input("please enter the temperature in Fahrenheit: "))
Celsius=(Fahrenheit-32)*(5/9)
print("{0}F is {1} in Celsius".format(Fahrenheit,Celsius))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.