Answer to Question #187849 in Python for Ali

Question #187849

Write a temperature converter program that uses lambda functions to convert from Fahrenheit to Celsius and vice versa. 



1
Expert's answer
2021-05-03T04:32:17-0400
ctf = lambda c:9/5*c+32
ftc = lambda f:((f-32)*5)/9


Flag=1
while(Flag):
    print("\n\nPress 1 to convert degree C to degree Farenhite: ")
    print("Press 2 to convert degree Farenhite to degree C: ")
    print("Press 0 to QUIT")
    Flag = int(input("Enter Option (0/1/2): "))
    if(Flag==1):
        c=int(input("Enter Temperature in (C):"))
        f = ctf(c)
    if(Flag==2):
        c=int(input("Enter Temperature in (F):"))
        c = ftc(f)
    print("\nTemperature in (F) : %.1f"%f)
    print("Temperature in (C) : %.1f"%c)

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