Write a Python program to convert temperatures to and from celsius, fahrenheit.
[ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ]
Expected
Output :
60°C is 140 in Fahrenheit
45°F is 7 in Celsius
def far_to_cel(f):
c = (f - 32) * 5/9
return int(c + 0.5)
def cel_to_far(c):
f = c * 9/5 + 32
return int (f + 0.5)
def main():
c = 60
f = cel_to_far(c)
print(f'{c}°C is {f} in Fahrenheit')
f = 45
c = far_to_cel(f)
print(f'{f}°F is {c} in Celsius')
if __name__ == '__main__':
main()
Comments
Leave a comment