For this task we were asked to create a program in which the user will prompt a temperature in Fahrenheit and convert it into Celsius The program also had to sate if water would boil at the temperature given by the user.
In this exercise we´ll be using function to strength the knowledge from the past post.
1.- First define your function and make it return a value:
def fahrenheit (x):
return (5*(x-32)/9)
2.- Declare your variable, remember to make an input on it so the user can type a value:
x= float(input(("Temperature you would like to convert")))
c=fahrenheit (x)
3.- Print the answer:
print ("That´s", c, "celsisus degrees")
4.- Use an "If" function to get the program to tell you if water will boil or not:
if x<212:
print ("Water does not Boil at this temperature")
else:
print ("Water will Boil")
Complete code:
print ("Converting Fahrenheit to Celsius")
def fahrenheit (x):
return (5*(x-32)/9)
x= float(input(("Temperature you would like to convert")))
c=fahrenheit (x)
print ("That´s", c, "celsisus degrees")
if x<212:
print ("Water does not Boil at this temperature")
else:
print ("Water will Boil")
#WSQ02
No hay comentarios:
Publicar un comentario