Author Archives: sergio

using comments in python

1 min read

to leave comments in python use # for a one line comment 

# comment

for multiline comments use ” ” ” 

“”” comment

    comment

“””

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

WSQ03-Fun with numbers

1 min read

#WSQ03 #TC1014

this time the program has to ask the user for two integers and calculate sum, difference, product, division (no decimals) and remainder.

lets start with the input function so we can enter the numbers for the operations. use a variable like “x” and write this:

x = int(input())  

also you can add text in the input function to tell the user what you want him to input:

x = int(input(“enter an integer: “)

repeat the line with another variable like “y” 

y = int(input(“enter an integer: “)

now let’s start with the calculations, set a different variable for each one and the rigth operators: 

+, -, *, / and %

example: a = x+y

if you didn’t used the “int” function it won’t add them like 1+2=3 but it would go like this 1+2=12. that was my problem when writing the line.

finish the rest of the operations and then the print function:

print (a)  ——here goes the variable you want to print.

and thats it.

Mastery03

1 min read

·#Mastery03 #TC1014 

twitter: @nazare521

github: nazare52 

create a python file and run from command line

1 min read

#Mastery01

we are going to create a file for python so we can open it from cmd.

create a text file, I used windows notepad, and name it something like helloworld and change the extension to .py then open it. inside we write: print (“hello world”), save it.

open your cmd and it should say something like:

c:usersname>

we want to change the directory to find the file we created so we add “cd” like this:

c:usersname>cd          

add one space and write the directory where your file is, mine is in desktop:

c:usersname>cd C:UserssergioDesktop     

 and enter. now to open your file:

C:UserssergioDesktop>python helloworld.py

that should do it, for more information i found this video:

https://www.youtube.com/watch?v=hFhiV5X5QM4

WSQ01-I signed page one

WSQ01-setup Python

1 min read

#WSQ01

learning python

1 min read

just started 

just created this blog

just created this blog