WSQ05-Temperature

1 min read

#WSQ05 #TC1014

this assigment is to make a program that converts fahrenheit degrees to celsius with a number input from the user and let the program decide if water boils at that temperature and print the answer.

first the formula to convert fahrenheit to celsius is 5*(F-32)/9 and we will use it as a variable, ask for the input:

print (“temperature in fahrenheit?”)

f = int(input())

c = int(5*(f-32)/9)

sentence = “a temperature of {} degrees Fahrenheit is {} degrees in Celsius.”.format(f,c)

print (sentence)

that is the first part of the problem, in my last post I explained how to do that, if you want to take a look I’ll put a link at the end.

now we want to tell the program to print if the water boils at that temperature or not, to do that we use the statements if, elif and else. write “if” and then the conditional:

if (c>=100): 

  print (“water boils”)   — dejen un espacio antes de escribir print.

else:

  print (“water does not boil”)

you can use “elif”to add another conditional like:

elif (c

   print (“water is ice”)

and run it to see if it works. here are the links for my other post, to my code in github and the reference page for the “if” statement:

WSQ03-Fun with numbers:

http://tc1014.withknown.com/2015/wsq03-fun-with-numbers

my code in github:

https://github.com/nazare52/progra/blob/master/temperature.py

and the reference:

http://www.tutorialspoint.com/python/python_if_else.htm

CC BY 4.0 WSQ05-Temperature by sergio is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.