Aprende A Programar Pyhton

 Aprendiendo A Programar Python

Characters & Functions

# > Deshabilita cualquier función, y sirve para especificar que hace el código.

Print > Imprime lo que quieras que diga entre “” 

%d  > Poner variables en un string

", > Para poner espacio y después una variable

\n > Para poner el resultado de un nuevo renglón (escape double-quotes)

raw_input() >  is a way to Read a String from a Standard input device like a keyboard. 

Import > This is how you add features to your script from the Python feature set. Rather than give you all the features at once

argv > is the “argument variable,” introduce una variable (Input) nueva que puedes usar muchas veces. 

Text.Read > Read a archive

Text > Archive name

sys > is a package

“w+” > Open a program in write mode

“r+” > Read a program

“a+” > Append a program


+ plus

- minus

/ slash

* asterisk

% percent

< less-than

> greater-than

<= less-than-equal

>= greater-than-equal


Variables: In programming, a variable is nothing more than a name for something so you can use the name rather than the something as you code.


cars = 100

space_in_a_car = 4.0

drivers = 30

passengers = 90

cars_not_driven = cars - drivers

cars_driven = drivers

carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven


How can I print without spaces between words in print?

You do it like this: print "Hey %s there." % "you". You will do more of this soon.


-9 print "Let's talk about %s." % my_name

-10 print "He's %d inches tall." % my_height

-11 print "He's %d pounds heavy." % my_weight


*Donde va el % de dentro del string va lo que pones afuera


Modules: “features” here (these little things you import to make your Python program do more) but nobody else calls them features.


Command, Functions, Methods: You give a file a command by using the . (dot or period), the name of the command, and parameters. 

• close—Closes the file. Like File->Save.. in your editor.

• read—Reads the contents of the file. You can assign the result to a variable.

• readline—Reads just one line of a text file.

• truncate—Empties the file. Watch out if you care about the file.

• write(stuff)—Writes stuff to the file


Exists> This returns True if a file exists, based on its name in a string as an argument


Functions (def) Then we end this line with a : colon and start indenting. 

1. They name pieces of code the way variables name strings and numbers.

2. They take arguments the way your scripts take argv.

3. Using #1 and #2, they let you make your own “mini-scripts” or “tiny commands.”

4. This means you can make your own commands and use them in your scripts too.


Entradas populares de este blog

Aliens En Nuevo Laredo

Is IQ Inherit?

Automating Everything With Python Notes