Tuesday, June 3, 2014

Fahrenheit To Celsius Converter in Python


In this article I will share with you a sample program that I wrote using Python programming language I called this program Fahrenheit To Celsius Converter in Python. I have already written this type of program in other programming languages in Visual Basic 6, Visaul Basic NET,C, C++, Java and PHP. I would like to try to convert the code using in Python in this program I wrote a function to solve and convert the temperature given in Fahrenheit into its Celsius equivalent. To find the Celsius temperature we are using this formula (°F - 32) x 5/9 = °C.

def  convert_to_celsius(fahrenheit):
  celsius = (fahrenheit - 32) * 5.0/9.0
  print("Temperature is Celsius is {:.2f}".format(celsius));
  return

Function in Python to solve the Celsius temperature equivalent

I hope you find my work useful and Thank you very much.



Sample Output of Our Program


Python Integrated Programming Environment


Program Listing

# Fahrenheit To Celsius Converter
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 3, 2014 Monday

def  convert_to_celsius(fahrenheit):
  celsius = (fahrenheit - 32) * 5.0/9.0
  print("Temperature is Celsius is {:.2f}".format(celsius));
  return

print("\n")
print("@==================================@")
print("  Fahrenheit To Celsius Converter     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 temp = int(input("Kindly Enter Temperature in Fahrenheit :=> "))
 print("");
 convert_to_celsius(temp);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")       






1 comment: