Answer to Question #329934 in Python for Shubham Tiwari

Question #329934

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


1
Expert's answer
2022-04-17T18:34:30-0400
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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS