1 min read
to leave comments in python use # for a one line comment
# comment
for multiline comments use ” ” ”
“”” comment
comment
“””
1 min read
to leave comments in python use # for a one line comment
# comment
for multiline comments use ” ” ”
“”” comment
comment
“””
Comments Off on using comments in python
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #Mastery07, #TC1014
1 min read
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:/
my code in github:
https:/
and the reference:
1 min read
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.
Comments Off on WSQ03-Fun with numbers
Posted in Blogs, Syndicated, TC1014 Blogs
1 min read
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:
Comments Off on create a python file and run from command line
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #mastery01
1 min read
I signed page one: http:/
1 min read
1 min read
just started
Comments Off on learning python
Posted in Blogs, Syndicated, TC1014 Blogs
just created this blog
Comments Off on just created this blog
Posted in Blogs, Syndicated, TC1014 Blogs