How to Convert Celsius to Fahrenheit on Python


The Celsius temperature scale defines that water freezes at zero degrees and boils at 100 degrees. This scale is commonly used in many countries around the globe. Despite that fact, the United States continues to use the Fahrenheit scale. The mathematical formula for the conversion between degrees of Celsius (C) and Fahrenheit (F) is as follows: F=(9/5) * C +32. Python is a modern, high-level programming language. It allows you to write a simple four-line script to convert the temperature to Fahrenheit.

  • Use the "input" function to accept the temperature value in Celsius:

    C=input ("Enter the Temperature in Celsius: ")

    This command produces the message ("Enter the Temperature in Celsius: ") and require you to input a value; this value is assigned to the variable "C."

  • Divide 9 by 5 and assign the result to the variable "coefficient" using the command;

    coefficient = 9.0/5.0

  • Multiply the temperature by the variable "coefficient" and add 32 to calculate Fahrenheit; then assign the result to the variable "F:" F=C* coefficient + 32

  • Output the result using the print statement;

    print "Temperature in Fahrenheit is ", F

    For example, if you enter the temperature of 30 Celsius the output is "Temperature in Fahrenheit is 86.0."

Related Searches


Promoted By Zergnet



You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!