¿Qué es Python?
El lenguaje más recomendado para empezar. Y vas a escribirlo acá mismo, sin instalar absolutamente nada.
What is Python?
The most recommended language to start with. And you will write it right here, with nothing installed.
Programar es escribir instrucciones que el computador va a seguir al pie de la letra. Como una receta, pero para una máquina que no entiende nada por su cuenta.
Python se hizo famoso porque esas instrucciones se leen casi como inglés. Compara cómo se dice "muestra esto en pantalla" en dos lenguajes:
Python print("Hola")
JavaScript console.log("Hola");
Menos símbolos, menos cosas que se te pueden olvidar. Por eso es el más recomendado para partir.
Programming is writing instructions the computer will follow to the letter. Like a recipe, but for a machine that understands nothing on its own.
Python became famous because those instructions read almost like English. Compare how you say "show this on screen" in two languages:
Python print("Hello")
JavaScript console.log("Hello");
Fewer symbols, fewer things to forget. That is why it is the most recommended starting point.
La instrucción más básica es print(): muestra en pantalla lo que le pongas
entre paréntesis.
Abajo hay Python de verdad. Escribe tu nombre entre las comillas y aprieta Ejecutar.
The most basic instruction is print(): it shows whatever you put between the
brackets.
Below is real Python. Type your name between the quotes and hit Run.
Estas dos líneas se parecen pero significan cosas distintas. Ejecuta y mira la diferencia:
These two lines look alike but mean different things. Run it and see:
Lo que va después de # es un comentario:
una nota para ti que Python ignora por completo.
Whatever comes after # is a comment:
a note for you that Python ignores entirely.
Esto es lo más importante del tutorial y casi nadie lo dice al principio: vas a equivocarte todo el tiempo, y está bien.
Programar no es escribir todo perfecto a la primera. Es escribir algo, ver que falla, entender por qué, y arreglarlo. Quien lleva veinte años haciéndolo también se equivoca constantemente; solo aprendió a leer los errores más rápido.
Ejecuta esto y mira el mensaje rojo:
This is the most important part of the tutorial and almost nobody says it up front: you will make mistakes constantly, and that is fine.
Programming is not getting it perfect first try. It is writing something, watching it fail, understanding why, and fixing it. People with twenty years of experience also make mistakes constantly; they just read the errors faster.
Run this and look at the red message:
Dice SyntaxError, que significa "no entiendo cómo está
escrito". Arréglalo: agrega la comilla que falta antes del paréntesis y vuelve
a ejecutar.
En Python los errores más comunes tienen nombres que conviene reconocer:
SyntaxError— está mal escrito (falta una comilla, un paréntesis, dos puntos).NameError— usaste algo que no existe, casi siempre por una falta de ortografía.TypeError— mezclaste tipos que no se pueden mezclar, como texto con número.IndentationError— los espacios del principio no calzan. Este lo verás pronto.
It says SyntaxError, meaning "I do not understand how
this is written". Fix it: add the missing quote before the bracket and run
again.
In Python the most common errors have names worth recognising:
SyntaxError— badly written (missing a quote, a bracket, a colon).NameError— you used something that does not exist, usually a typo.TypeError— you mixed types that cannot mix, like text and number.IndentationError— the leading spaces do not line up. You will meet this one soon.
Que programar es dar instrucciones exactas. Que print() muestra cosas. Que las
comillas separan el texto de los números. Que # escribe notas. Y que los errores
son parte del trabajo, no una señal de que no sirves para esto.
Ahora vamos a hacer que el programa recuerde.
That programming is giving exact instructions. That print() shows things. That
quotes separate text from numbers. That # writes notes. And that errors are part
of the job, not a sign you are not cut out for this.
Now let us make the program remember.