Answer to Question #187812 in Python for Ali

Question #187812

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



1
Expert's answer
2021-05-03T17:07:45-0400
# Python temperature converter program that uses lambda functions to convert from Fahrenheit to Celsius and vice versa.
celciusToFahrenheit = lambda c: 9 / 5 * c + 32
fahrenheitToCelcius = lambda f: ((f - 32) * 5) / 9

choice = 1
while choice:
    print("Please select an option\n")
    print("1- to convert degree Celsius to degree Fahrenheit")
    print("2- to convert degree Fahrenheit to degree Celsius")
    print("0- to quit")
    choice = int(input("Enter your option: "))
    if choice == 1:
        c = int(input("Enter Temperature in degrees Celsius:"))
        f = celciusToFahrenheit(c)
        print("\nTemperature in degrees Fahrenheit is : %.1f" % f)
    if choice == 2:
        f = int(input("Enter Temperature in Fahrenheit:"))
        c = fahrenheitToCelcius(f)
        print("\nTemperature in degrees Celsius is : %.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