calculations

Python code|Convert Celsius to Fahrenheit

Python code|Convert Celsius to Fahrenheit

In this article, we will discuss the concept of  the Python code|Convert Celsius to Fahrenheit

In this post, we will learn how to write a program to Convert from Celsius into Fahrenheit and display the result on the screen. Here, we have four methods and explain how to calculate Fahrenheit using the given Celsius value and display the result on the screen in Python programming language.

Code to Celsius into Fahrenheit

Convert Celsius into Fahrenheit -#1

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

Program 1

# Python program to convert temperature in Celsius to Fahrenheit
celsius=67.5
#Declare and initialize variables

#Calculate Fahrenheit
fahrenheit=(celsius*1.8)+32
#print result
print('%0.1f degree Celsius is equal to %0.1f degrees Fahrenheit' %(celsius,fahrenheit))

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

67.5 degree Celsius is equal to 153.5 degrees Fahrenheit

 

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

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

Program 2

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

#Calculate Fahrenheit
fahrenheit=(celsius*1.8)+32

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

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

Enter temperature in Celsius 100.00
100.0 degree Celsius is equal to 212.0 degrees Fahrenheit

 

Convert Celsius into Fahrenheit -Using function-#3

In this program, the user declares a double variable as a parameter for Celsius(c) in the user-defined function. When the user runs the program (when calling the function), the value for Celsius passes as an argument to the function.
Finally, the Fahrenheit 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 Celsius to Fahrenheit
#uaing user-defined function
def convertCelsToFahre(c):#user defined function
    #Calculate the temperature of Fahrenheit
    f=(c*1.8)+32
    return f

celsius=90.00
#Declare and initialize variables

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

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

90.0 degree Celsius is equal to 194.0 degrees Fahrenheit

 

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

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

Program 4

# Python code to convert temperature in Celsius to Fahrenheit
#uaing user defined function
def convertCelsToFahre(c):#user defined function
    #Calculate temperature Fahrenheit
    f=(c*1.8)+32
    return f

celsius=float(input("Enter temperature in Celsius "))
#Ask input from the user

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

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

Enter temperature in Celsius 101
101.0 degree Celsius is equal to 213.8 degrees Fahrenheit

 

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

Subtract two numbers using method overriding

Subtract two numbers using method overriding   Program 1

3 months ago

PHP Star triangle Pattern program

PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…

3 months ago

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,…

1 year 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…

1 year ago

Write temperature conversion program: Fahrenheit into Celsius

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

1 year 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…

1 year ago

This website uses cookies.