'''LAB 3 : Write a menu driven Program to accept temperature
from the user and perform conversion to celcius or farenheit
as per the choice. Use modules that contain functions
to execute the required conversions'''
conversions.py
'''Module to convert between Farenheit and Celcius degrees'''
def faren_cel(f):
'''accepts temperature in farenheit and returns the value in celcius'''
return (f-32)*5/9
def cel_faren(c):
'''accepts temperature in celcius and returns the value in farenheit'''
return (c*9/5)+32
temperature.py
import conversions
print(help(conversions))
while True:
ch = int(input("""Menu:
1) Convert from farenheit to celcius
2) Convert from celcius to farenheit
3) Exit"""))
if ch==1:
temp=float(input("Enter the temperature in Farenheit"))
cel=faren_cel(temp)
print(f"It is {round(cel,2)} degrees in Celcius")
elif ch==2:
temp=float(input("Enter the temperature in Celcius"))
far=cel_faren(temp)
print(f"It is {round(far,2)} degrees in Farenheit")
else:
break
No comments:
Post a Comment