Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def isFloating(x):
- try:
- float(x) #Test if the inserted value is a floating point number (a number such as 3.14 or 1(.0))
- return True
- except:
- return False #If the float(x) thing didn't work, it'll return False.
- celsius = "" #Create a blank string value for celsius.
- while not isFloating(celsius): #So long is celsius is not a floating point number, it'll loop this forever
- celsius = input("Insert the temperature in degrees Celsius: ") #User input
- fahrenheit = float(celsius) * 1.8 + 32 #Implementation of formula: F = C * 1.8 + 32
- print("It is " + str(fahrenheit) + " degrees Fahrenheit.") #Print the results
Advertisement
Add Comment
Please, Sign In to add comment