calculations

Program to Convert Fahrenheit into Celsius in Python

Program to Convert Fahrenheit into Celsius in Python

In this article, we will discuss the concept of the Program to Convert Fahrenheit into Celsius in Python

In this post, we will learn how to write a program to Convert Fahrenheit into Celsius. Celsius is calculated, and display the result on the screen using the Fahrenheit value 

Here, we have four methods and explain how to calculate Celsius using the given Fahrenheit value and display the result on the screen in Python programming language.

Code to Convert Fahrenheit into Celsius

Convert Fahrenheit into Celsius  -#1

In this program, the user declares two variables as Celsius and Fahrenheit and initiates the value as 42.0 to Fahrenheit. Then the scientific equation will convert it from Fahrenheit into Celsius in the Python programming language.

Program 1

# Python program to convert temperature in  Fahrenheit to Celsius 
fahrenheit=42#Declare and initialize variabe
#Calculate celsius
celsius=((fahrenheit-32)*5)/9

#Dispay resut
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

42.0 degrees Fahrenheit is equal to 5.6 degree Celsius

 

Convert Fahrenheit into Celsius  -Entered by the user-#2

In this program, the user declares two variables as Celsius and Fahrenheit. The program asks for the value from the user to Fahrenheit then the given input will convert from Fahrenheit into Celsius in the Python programming language using the scientific equation.

Program 2

# Python program to convert temperature in  Fahrenheit to Celsius 
fahrenheit=float(input("Enter temperature in Fahrenheit "))
#Ask input from the user

#Calculate celsius
celsius=((fahrenheit-32)*5)/9

#Display result
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

Enter temperature in Fahrenheit 100
100.0 degrees Fahrenheit is equal to 37.8 degree Celsius

 

Convert Fahrenheit into Celsius  -Using function-#3

In this program, the user declares a double variable as a parameter for Fahrenheit(F) in the user-defined function. When the user runs the program (when calling the function), the value for Fahrenheit passes as an argument to the function.
Finally, the Celsius value is calculated and displayed on the screen using the scientific equation in the Python programming language..

Program 3

# Python program to convert temperature in Fahrenheit to Celsius
#using function
def convertFahreToCels(F):#user defined function
    #Calculate temperature in Celsius
    C=(F-32)/1.8
    return C

fahrenheit=212.00
#Declare and initialize variabe

#Calling the finction to calculate celsius
celsius=convertFahreToCels(fahrenheit)
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius ' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

212.0 degrees Fahrenheit is equal to 100.0 degree Celsius

 

Convert Fahrenheit into Celsius Using the function-Entered by the user-#4

In this program, the user declares a double variable as a parameter for Fahrenheit(F) in the user-defined function. When the user runs the program (when calling the function), The program asks for the value from the user to Fahrenheit and the value for Fahrenheit passes as an argument to the function.
Finally, the Celsius value is calculated and displayed on the screen using the scientific equation.

Program 4

# Python program to convert temperature in Fahrenheit to Celsius
#using function
def convertFahreToCels(F):#user defined function
    #Calculate temperature in Celsius
    C=(F-32)/1.8
    return C

fahrenheit=float(input("Enter temperature in Fahrenheit "))
#Ask input from the user

#Calling the function
celsius=convertFahreToCels(fahrenheit)
#Display result
print('%0.1f degrees Fahrenheit is equal to %0.1f degree Celsius ' %(fahrenheit,celsius))

When the above code is executed, it produces the following result

Enter temperature in Fahrenheit 112
112.0 degrees Fahrenheit is equal to 44.4 degree Celsius

 

Similar post

Celsius into Fahrenheit in the C program

Fahrenheit into Celsius in C program

Celsius into Fahrenheit in C++ program

Fahrenheit into Celsius in C++ program

Celsius into Fahrenheit in the C# program

Fahrenheit into Celsius in C# program

Convert Celsius into Fahrenheit in Python

Convert Fahrenheit into Celsius in Python

 

Karmehavannan

Recent Posts

Using function or method to Write temperature conversion : Fahrenheit into Celsius

Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…

11 months ago

Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user

Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…

11 months ago

Write temperature conversion program: Fahrenheit into Celsius

Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…

11 months ago

How to write a program to convert Fahrenheit into Celsius

How to write a program to convert Fahrenheit into Celsius In this article, we will…

11 months ago

Function/method to convert Celsius into Fahrenheit -Entered by user

Function/method to convert Celsius into Fahrenheit -Entered by user In this article, we will discuss…

11 months ago

Temperature conversion: Celsius into Fahrenheit using function or method

Temperature conversion: Celsius into Fahrenheit using a function or method In this article, we will…

11 months ago

This website uses cookies.