# Python program to convert temperature from Celsius to Fahrenheit and vice-versa

In this Python program, we are going to learn how to convert Fahrenheit to Celsius and Celsius to Fahrenheit?
Submitted by Ankit Rai, on June 06, 2019

Formula used:

```
Celsius to Fahrenheit:  °C= (5/9)*(°F-32)
Fahrenheit to Celsius:  °F= (9/5)*(°C) + 32

```

Code:

```# Define a function to convert
# celsius temperature to Fahrenheit
def Celsius_to_Fahrenheit(c) :

f = (9/5)*c + 32

return f

# Define a function to convert
# Fahrenheit temperature to Celsius
def Fahrenheit_to_Celsius(f) :

c = (5/9)*(f - 32)

return c

# Driver Code
if __name__ == "__main__" :

c = 36
print(c, "degree celsius is equal to:",Celsius_to_Fahrenheit(c),"Fahrenheit")

f = 98
print(f,"Fahrenheit is equal to:",Fahrenheit_to_Celsius(f),"degree celsius")
```

Output

```    36 degree celsius is equal to: 96.8 Fahrenheit
98 Fahrenheit is equal to: 36.66666666666667 degree celsius
```

TOP Interview Coding Problems/Challenges

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates