Temperature often needs to be converted between different scales. In this article, we'll explore how to convert Celsius to Fahrenheit and Fahrenheit to Celsius using Python.
Celsius and Fahrenheit are two different measuring units to use to measure temperature. Celsius unit is widely used around the world, especially in scientific contexts where Fahrenheit is primarily used in the United States, its territories and associated states, and the Bahamas.
The formula to convert Celsius (C) to Fahrenheit (F) is given by:
- F = C x 9/5 + 32
The formula to convert Fahrenheit (F) to Celsius (C) is given by:
- C = 5/9 x (F - 32)
Python Program to Convert Celsius to Fahrenheit.
# Temperature in celsius degree celsius = float(input("Enter temperature in Celsius: ")) # Converting the celsius to # fehrenheit using the formula fahrenheit = (celsius * 9/5) + 32 # printing the result print('%.2f Celsius is equivalent to: %.2f Fahrenheit'% (celsius, fahrenheit))
Enter temperature in Celsius: 100 100.00 Celsius is equivalent to: 212.00 Fahrenheit
Python Program to Convert Fahrenheit to Celsius.
# Temperature in Fahrenheit degree fahrenheit = float(input("Enter temperature in Fahrenheit: ")) # Converting the Fahrenheit to # Celsius using the formula celsius = 5/9 * (fahrenheit - 32) # printing the result print('%.2f Fahrenheit is equivalent to: %.2f Celsius'% (fahrenheit, celsius))
Enter temperature in Fahrenheit: 212 212.00 Fahrenheit is equivalent to: 100.00 Celsius
No comments:
Post a Comment