TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Python Convert Celsius to Fahrenheit

Python Convert Celsius to Fahrenheit for beginners and professionals with programs on basics, controls, loops, functions, native data types etc.

<< Back to PYTHON

Python program to convert Celsius to Fahrenheit

In this tutorial, we will learn how to write a python program for converting degree Celsius temperature into degree Fahrenheit temperature.

Celsius:

Celsius is a unit of measurement for temperature, and it is also known as centigrade, and it is SI derived unit used by most of the countries worldwide.

It is named after the Swedish astronomer Anders Celsius.

Fahrenheit:

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

Suppose we have a temperature in degree Celsius, and our task is to convert the value of temperature into the degree Fahrenheit and display it.

Example:

Input: Temperature value in degree Celsius: 34 
Output: The 37.00 degree Celsius is equal to: 93.20-degree Fahrenheit

Input: Temperature value in degree Celsius: 40
Output: The 45.00 degree Celsius is equal to: 113.00-degree Fahrenheit

Approach:

We can input the degree Celsius temperature and apply the conversation formula of degree Fahrenheit from degree Celsius and display it on screen. The following is the relationship of degree Celsius and degree Fahrenheit:

T(�Fahrenheit)=(T(�Celsius)*1.8)+32

OR we can write:

T(�Fahrenheit)=(T(�Celsius)*9/5)+32

Example:

celsius_1 = float(input("Temperature value in degree Celsius: " ))

# For Converting the temperature to degree Fahrenheit by using the above
# given formula
Fahrenheit_1 = (celsius_1 * 1.8) + 32
  
# print the result
print('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
      %(celsius_1, Fahrenheit_1))

print("----OR----")
celsius_2 = float (input("Temperature value in degree Celsius: " ))
Fahrenheit_2 = (celsius_2 * 9/5) + 32
  
# print the result
print ('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
      %(celsius_2, Fahrenheit_2))

Output:

Temperature value in degree Celsius:  34
The 34.00 degree Celsius is equal to: 93.20 Fahrenheit
----OR----
Temperature value in degree Celsius:  23
The 23.00 degree Celsius is equal to: 73.40 Fahrenheit

To Convert Degree Fahrenheit into Degree Celsius:

The user can use the following formula for converting degree Fahrenheit into degree Celsius:

Python program to convert Celsius to Fahrenheit

Example:

Fahrenheit_1 = float( input("Temperature value in degree Fahrenheit: " ))

# For Converting the temperature from degree Fahrenheit to degree Celsius 
# by using the above given formula
celsius_1 = (Fahrenheit_1 - 32)  / 1.8
  
# Print the result
print ('The %.2f degree Fahrenheit is equal to: %.2f Celsius'
      %(Fahrenheit_1, celsius_1))

print("----OR----")
Fahrenheit_2 = float( input("Temperature value in degree Fahrenheit: " ))
celsius_2 = (Fahrenheit_2 - 32) * 5/9
  
# Print the result
print ('The %.2f degree Fahrenheit is equal to: %.2f Celsius'
      %(Fahrenheit_2, celsius_2))

Output:

Temperature value in degree Fahrenheit:  113
The 113.00-degree Fahrenheit is equal to: 45.00 Celsius
----OR----
Temperature value in degree Fahrenheit:  234
The 234.00-degree Fahrenheit is equal to: 112.22 Celsius

Conclusion

In this tutorial, we discussed how to write a Python program for converting degree Fahrenheit to degree Celsius and vice versa.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf