Use the round function to limit a floating-point result to 2 decimal places.
In your Fahrenheit to Celsius converter, you can round the result before displaying it.

Modified version of your code:

def main():
   printC(formeln(typeHere()))

def typeHere():
   global Fahrenheit
   try:
       Fahrenheit = int(raw_input("Hi! Enter Fahrenheit value, and get it in Celsius!\n"))
   except ValueError:
       print "\nYour insertion was not a digit!"
       print "We've put your Fahrenheit value to 50!"
       Fahrenheit = 50
   return Fahrenheit

def formeln(c):
   Celsius = (Fahrenheit - 32.00) * 5.00 / 9.00
   return round(Celsius, 2)

def printC(answer):
   print "\nYour Celsius value is {:.2f} C.\n".format(answer)

main()

This code uses round to limit the Celsius value to 2 decimal places and string formatting to always display two digits after the decimal, even for whole numbers.

Need Help With Python Development?

Work with our skilled Python developers to accelerate your project and boost its performance.

Hire Python Developers

Support On Demand!

Related Q&A