WRITE A PYTHON PROGRAM TO ENTER A TEMPERATURE IN (C) CONVERT (C) INTO (F) USING FUNCTIONS.
CODE FOR THE ABOVE PYTHON PROGRAM :
# write a py pro to enter a temperature in C and convert it into F by using functions.
def convert_temp(scale, temp):
if scale == "C":
return'F', (temp*(9/5)+32)
elif scale == "F":
return'C', (temp-32)*(5/9)
else:
print("its not in F or C")
#drivencode
scale = input("select (F) or (C) : ")
temp = int(input("enter the temperature:"))
s, t = convert_temp(scale, temp)
print(temp,"degrees",scale,"is",t,"degrees",s)
WRITTEN CODE FOR THE ABOVE PROGRAM :
# write a py pro to enter a temperature in C and convert it into F by using functions.
def convert_temp(scale, temp):
if scale == "C":
return'F', (temp*(9/5)+32)
elif scale == "F":
return'C', (temp-32)*(5/9)
else:
print("its not in F or C")
#drivencode
scale = input("select (F) or (C) : ")
temp = int(input("enter the temperature:"))
s, t = convert_temp(scale, temp)
print(temp,"degrees",scale,"is",t,"degrees",s)
OUTPUT :