CONVERT TEMPERATURE RESULTS FROM CELSIUS TO FAHRENHEIT IN PYTHON
Challenge:
Convert the provided temperature from Celsius to Fahrenheit given the degree-degree-day temperature. To achieve this, create a programme. the output to the nearest two decimal places
Note:
Python: To round ans to two decimal places, use round(ans,2).
Java: To round up to two decimal places, use Math.round(val*100, 100).
Note2:
You merely need to use the function given; you don’t need to accept any input on this issue.
Format for Input
There are how many test cases in the first line. The temperature will be represented by a single line of input in float format for each test scenario.
Format for Output
Temperature in float format
Typical Input
1
36.8
Sample Results:
98.24
Approach:
Mathematical Formula:
F = ( C * 1.8 ) +32
or
F = ( C * 9/5 ) + 32
Hint:
0°C = 32°F
Convert Celsius to Fahrenheit
#Celsius to Fahrenheit calculator
def ctf(c):
ctfc = (c * 9 // 5) + 32
return round(ctfc,2)
print(ctf(0))
Convert Fahrenheit to Celsius
#Fahrenheit to Celsius calculator
def ftc(f):
ftcc = (f - 32) * 5 // 9
return round(ftcc,2)
print(ftc(32))