Use «print» and comments…

When working on a lengthy code, there can be loads of confusions and errors since it is difficult to keep track of the function of so much text. There also can be plenty of bugs from working with a team of people, who all have a different style and way of seeing things. This is why comments exist.
To add a comment to a program just add the symbol “#” before you add the text. This will tell python “¡Hey, this is not for you, keep walking!” making python skip that line of text, so that it won’t count as part of the code.
Making use of comments you can add reminders of what a piece of text is for, where you need to pick up again in case you stop working, what a teammate needs to work in or how you think a piece of code will work.
Talking about code, do you remember when we talked about creating and running programs in python, and the text you wrote didn’t work because it was not code? Well, that’s because even if the text existed, it didn’t give any instructions to the computer to do anything.
Now we will practice doing something simple, print a phrase in the console. To accomplish this we will use the command “print” for python 3.
The way to correctly write the command is “print ()”, you will input whatever you want the computer to display between the parenthesis, using “” in case of a simple word or sentence, or simply write the values you have in the program as they are.
Example:
• Print (“You can’t see me”), the screen will display: You can’t see me
• Print (x), let’s say x=4, the screen will display: 4
You can also divide and organize the message any way you want to, making use of symbols like “+” or “,”:
• Print (“Call ” + “on me.”) Call on me
• Print (4 + 5)  45
As you can see, this is where it gets creepy. You see, by using the “+”, you are not giving out the instruction to make an addition of the values, just to print the two things together, that is why 4+5 = 45 instead of 9.
We must also be careful to not mix text with umbers, if we try to print this out: print (“Hi” + x), an error will appear, since “Hi” is a line of text and “x” represents (in this particular case) a number. In order to solve this mistake we must use a “,” instead of “+”: print (“Hi”, x), this way the computer will print both things, without trying to glue them together.

PuNUqdy

Publicado por: juansalvadorfernandez

Elegí estudiar ITE porque pienso que es una carrera versátil con la que se pueden lograr cosas muy interesantes. Aunque realmente no sé si alguna otra carrera me gustaría más, las personas terminan haciendo lo que les gusta, independientemente de la carrera que estudien. Si alguien me pregunta quien es mi héroe, sería mi padre, pues es una persona fuerte que en momento de necesidad sacó adelante a su familia, pagó los estudios de sus hermanos, es un profesionista que disfruta de su trabajo y que tiene metas fijas y aspira a ellas con todas sus fuerzas. Hace tiempo tocaba la flauta dulce e intenté aprender a tocar piano, teclado y guitarra. No me gusta el deporte. Realmente no tengo un autor ni un libro favorito, siento que me falta encontrar un tema o un estilo que realmente me guste.

EtiquetasDeja un comentario

Deja un comentario