These are the two temperature scales that are most commonly used:
Most nations use the metric temperature system known as Celsius (symbol: °C). Under typical meteorological circumstances, water has a freezing point of 0 degrees Celsius and a boiling temperature of 100 degrees Celsius, according to the Celsius system. The United States and a few other nations predominantly use the Fahrenheit (symbol: °F) unit of measurement. According to the Fahrenheit scale, under typical climatic circumstances, water has a freezing point of 32 degrees Fahrenheit and a boiling temperature of 212 degrees Fahrenheit.
Using the formula below, we can change the temperature from Celsius to Fahrenheit:
where is the Fahrenheit temperature and is the Celsius temperature.
We need to apply the formula above to a temperature value that has been provided to convert it from Celsius to Fahrenheit.
Let’s suppose we have a temperature of 30 degrees Celsius. Let’s put the value of in the formula above,
Given ,
Let’s see an example of converting a temperature in Celsius to Fahrenheit in Python:
c = 30# Using formulaf = (c * 9/5) + 32print("After converting celsius to fahrenheit the value is", f)
Here’s the line-to-line explanation of the code above:
c
with a value of 30.f
.f
by displaying a message on the screen.Free Resources