# How to Convert Celsius To Fahrenheit using Python?

In this article, we will show you how to convert Celsius To Fahrenheit using Python.

Celsius

Celsius is a temperature measurement unit that is also known as centigrade. It is an SIderived unit that is used by the majority of countries throughout the world.

It is named after the Swedish astronomer Anders Celsius.

Fahrenheit

Fahrenheit is a temperature scale named after the Polish-born German physicist Daniel Gabriel Fahrenheit, and it uses degrees Fahrenheit as a temperature unit.

To obtain Fahrenheit equivalent of celsius, multiply by 1.8 and add 32 -

f=c*1.8+32


Or we can use another formula −

f=(c*9/5)+32


## Converting Celsius To Fahrenheit using the first formula f=c*1.8+32

### Algorithm (Steps)

Following are the Algorithm/steps to be followed to perform the desired task −

• Create a variable to store the input celsius degree temperature.

• Use the mathematical formula f=c*1.8+32 to convert the input celsius degree temperature to Fahrenheit degree temperature.

• Print the Fahrenheit equivalent of the given input celsius degree temperature.

### Example

The following program converts the given input celsius degree temperature to Fahrenheit degree temperature using the formula f=c*1.8+32 −

# input celsius degree temperature
celsius_temp = 45
# converting celsius degree temperature to Fahrenheit
fahrenheit_temp =celsius_temp*1.8+32
# printing the Fahrenheit equivalent of the given input celsius degree
print("The Fahrenheit equivalent of 45 celsius = ", fahrenheit_temp)


### Output

On executing, the above program will generate the following output −

The Fahrenheit equivalent of 45 celsius = 113.0


## Converting Celsius To Fahrenheit using f=(c*9/5)+32

### Algorithm (Steps)

Following are the Algorithm/steps to be followed to perform the desired task −

• Create a variable to store the input celsius degree temperature.

• Use the mathematical formula f=(c*9/5)+32 to convert the input celsius degree temperature to Fahrenheit degree temperature.

• Print the Fahrenheit equivalent of the given input celsius degree temperature.

### Example

The following program converts the given input celsius degree temperature to Fahrenheit degree temperature using the formula f=(c*9/5)+32 −

# input celsius degree temperature
celsius_temp = 45
# converting celsius degree temperature to Fahrenheit
fahrenheit_temp = (celsius_temp*9/5)+32
# printing the Fahrenheit equivalent of celsius
print("The Fahrenheit equivalent of 45 celsius = ", fahrenheit_temp)


### Output

On executing, the above program will generate the following output −

The Fahrenheit equivalent of 45 celsius = 113.0


## Converting Celsius To Fahrenheit using User Defined Function

### Algorithm (Steps)

Following are the Algorithm/steps to be followed to perform the desired task −

• Create a function convertCelsiustoFahrenheit(), which converts the given celsius degree temperature to Fahrenheit degree temperature

• Use the mathematical formula f=(c*9/5)+32 to convert the passed celsius degree temperature to Fahrenheit degree temperature to the function.

• Return Fahrenheit degree temperature of passed celsius temperature.

• Create a variable to store the input celsius degree temperature.

• Call the convertCelsiustoFahrenheit() function by passing the input celsius as an argument.

• Print the Fahrenheit equivalent of the given celsius degree temperature

### Example

The following program converts the given input celsius degree temperature to Fahrenheit degree temperature using the user-defined function and formula f=(c*9/5)+32 −

# creating a function that converts the given celsius degree temperature
# to Fahrenheit degree temperature
def convertCelsiustoFahrenheit(c):
# converting celsius degree temperature to Fahrenheit degree temperature
f = (9/5)*c + 32
# returning Fahrenheit degree temperature of given celsius temperature
return (f)
# input celsius degree temperature
celsius_temp = 80
print("The input Temperature in Celsius is ",celsius_temp)
# calling convertCelsiustoFahrenheit() function by passing
# the input celsius as an argument
fahrenheit_temp = convertCelsiustoFahrenheit(celsius_temp)
# printing the Fahrenheit equivalent of the given celsius degree temperature
print("The Fahrenheit equivalent of input celsius degree = ", fahrenheit_temp)


### Output

On executing, the above program will generate the following output −

The input Temperature in Celsius is 80
The Fahrenheit equivalent of input celsius degree = 176.0


### Conclusion

We learned what celsius temperature is and Fahrenheit temperature is in this article. We also learned how to convert them using mathematical formulas. We also learned how to write a user-defined function that takes a Celsius temperature as an argument, transforms it to Fahrenheit, and returns it.