Sunteți pe pagina 1din 27

>>> introduction to Python

"Los programadores del mañana son los magos del futuro. Programar es crear algo completamente nuevo desde cero."

Mark Zuckerberg, fundador de Facebook

magos del futuro. Programar es crear algo completamente nuevo desde cero." Mark Zuckerberg, fundador de Facebook
magos del futuro. Programar es crear algo completamente nuevo desde cero." Mark Zuckerberg, fundador de Facebook

>>> introduction to Python

> > > introduction to Python https://www.youtube.com/watch?v=7vbi-OCFZEY
https://www.youtube.com/watch?v=7vbi-OCFZEY
https://www.youtube.com/watch?v=7vbi-OCFZEY
> > > introduction to Python https://www.youtube.com/watch?v=7vbi-OCFZEY
> > > introduction to Python https://www.youtube.com/watch?v=7vbi-OCFZEY
> > > introduction to Python https://www.youtube.com/watch?v=7vbi-OCFZEY

>>> introduction to Python

> > > introduction to Python High-level, open, multiplatform programming language. Simple grammar and
> > > introduction to Python High-level, open, multiplatform programming language. Simple grammar and
High-level, open, multiplatform programming language. Simple grammar and easy to learn! Used in web programming,
High-level, open, multiplatform programming language.
Simple grammar and easy to learn!
Used in web programming, mobile, server, scientific
computing, maths, artificial intelligence
grammar and easy to learn! Used in web programming, mobile, server, scientific computing, maths, artificial intelligence
grammar and easy to learn! Used in web programming, mobile, server, scientific computing, maths, artificial intelligence

>>> introduction to Python

> > > introduction to Python
> > > introduction to Python
> > > introduction to Python

>>> introduction to Python

> > > introduction to Python
> > > introduction to Python
> > > introduction to Python
> > > introduction to Python
> > > introduction to Python
> > > introduction to Python
> > > introduction to Python

>>> introduction to Python

> > > introduction to Python +
> > > introduction to Python +

+

> > > introduction to Python +

>>> introduction to Python

#Programa per calcular el major numero num1 = 18 num2 = 14 num3 = 12

if (num1 >= num2) and (num1 >= num3):

mayor = num1 elif (num2 >= num1) and (num2 >= num3):

mayor = num2 else:

mayor = num3

print ("El mayor numero entre " + str(num1) + ", " + str(num2) + " y " + str(num3) + " es " + str(mayor))

mayor numero entre " + str(num1) + ", " + str(num2) + " y " +
mayor numero entre " + str(num1) + ", " + str(num2) + " y " +

>>> print (“learning python”);

> > > print (“learning python”); We need an interpreter to run scripts Editor vs console
We need an interpreter to run scripts Editor vs console In console: type python3 >>>
We need an interpreter to run scripts
Editor vs console
In console: type python3
>>>
need an interpreter to run scripts Editor vs console In console: type python3 >>> https://codeanywhere.com
need an interpreter to run scripts Editor vs console In console: type python3 >>> https://codeanywhere.com
need an interpreter to run scripts Editor vs console In console: type python3 >>> https://codeanywhere.com

>>> print (“learning python”);

> > > print (“learning python”); string = “hola” integer = 3 float = 2.51 boolean
string = “hola” integer = 3 float = 2.51 boolean = True/False (cadena de caracteres)
string = “hola”
integer = 3
float = 2.51
boolean = True/False
(cadena de caracteres)
(entero)
(decimal)
(booleano)
= “hola” integer = 3 float = 2.51 boolean = True/False (cadena de caracteres) (entero) (decimal)
= “hola” integer = 3 float = 2.51 boolean = True/False (cadena de caracteres) (entero) (decimal)
= “hola” integer = 3 float = 2.51 boolean = True/False (cadena de caracteres) (entero) (decimal)

>>> print (“learning python”);

> > > print (“learning python”); print (“hello world!) print(2 + 2) #Comment in one single
print (“hello world!) print(2 + 2) #Comment in one single line
print (“hello world!)
print(2 + 2)
#Comment in one single line

Strings and integers are built-in types

python”); print (“hello world!) print(2 + 2) #Comment in one single line Strings and integers are

>>> print (“learning python”);

> > > print (“learning python”); Read them! SyntaxError (something misspelled) NameError
> > > print (“learning python”); Read them! SyntaxError (something misspelled) NameError
Read them! SyntaxError (something misspelled) NameError (undefined/unknown variable) IndexError(when accessing lists)
Read them!
SyntaxError
(something misspelled)
NameError (undefined/unknown variable)
IndexError(when accessing lists)
Read them! SyntaxError (something misspelled) NameError (undefined/unknown variable) IndexError(when accessing lists)
Read them! SyntaxError (something misspelled) NameError (undefined/unknown variable) IndexError(when accessing lists)

>>> print (“learning python”);

> > > print (“learning python”);
> > > print (“learning python”);

>>> print (“learning python”);

> > > print (“learning python”); Suma = 5 + 2 Resta = 80 - 29
Suma = 5 + 2 Resta = 80 - 29 Multiplicación = 33 * 2
Suma = 5 + 2
Resta = 80 - 29
Multiplicación = 33 * 2
División = 40 / 3
Modulo (resto división) = 3 % 2
Potencia = 2 ** 5

>>> print (“learning python”);

> > > print (“learning python”);
> > > print (“learning python”);
> > > print (“learning python”);

>>> print (“learning python”);

> > > print (“learning python”); To create formulas to use with different values side =
To create formulas to use with different values side = 2 area = side *
To create formulas to use with different values
side = 2
area = side * side
print (area)

>>> print (“learning python”);

> > > print (“learning python”); this_is_a_normal_name = 7 this_also2 = 7 DON’T USE: spaces, -,

this_is_a_normal_name = 7 this_also2 = 7

DON’T USE: spaces, -, number at the beginning, strange characters, Ex: 2-this, mi variable, mi-variable

this_also2 = 7 DON’T USE: spaces, -, number at the beginning, strange characters, Ex: 2-this, mi
this_also2 = 7 DON’T USE: spaces, -, number at the beginning, strange characters, Ex: 2-this, mi

>>> print (“learning python”);

> > > print (“learning python”); x = 7 print(x) x = “yuhu” print(x) (the last

x = 7 print(x)

x = “yuhu”

print(x)

(the last value)

> > > print (“learning python”); x = 7 print(x) x = “yuhu” print(x) (the last
> > > print (“learning python”); x = 7 print(x) x = “yuhu” print(x) (the last
> > > print (“learning python”); x = 7 print(x) x = “yuhu” print(x) (the last

>>> print (“learning python”);

> > > print (“learning python”); nombre = "Aina" edad = "35" comida =
> > > print (“learning python”); nombre = "Aina" edad = "35" comida =
nombre = "Aina" edad = "35" comida = "brownie" ‘My name\’s “Aina” and I\’m a
nombre = "Aina"
edad = "35"
comida = "brownie"
‘My name\’s “Aina” and I\’m a programmer’
= "Aina" edad = "35" comida = "brownie" ‘My name\’s “Aina” and I\’m a programmer’
= "Aina" edad = "35" comida = "brownie" ‘My name\’s “Aina” and I\’m a programmer’

>>> print (“learning python”);

> > > print (“learning python”); message = “””Message in three lines””” print (message)
message = “””Message in three lines””” print (message)
message = “””Message
in three
lines”””
print (message)
> > > print (“learning python”); message = “””Message in three lines””” print (message)
> > > print (“learning python”); message = “””Message in three lines””” print (message)

>>> print (“learning python”);

> > > print (“learning python”); primera_letra = “AINA”[0] “hello” + “world”
primera_letra = “AINA”[0] “hello” + “world” ‘hello’ * 3 ‘My name is “Aina”’
primera_letra = “AINA”[0]
“hello” + “world”
‘hello’ * 3
‘My name is “Aina”’

>>> print (“learning python”);

> > > print (“learning python”); len(“hola”) HOLA.lower() hola.upper() str(2) longitud
len(“hola”) HOLA.lower() hola.upper() str(2) longitud minúsculas mayúsculas convertir nº a String x =
len(“hola”)
HOLA.lower()
hola.upper()
str(2)
longitud
minúsculas
mayúsculas
convertir nº a String
x = "J123"; x.isalpha() ¿solo caracteres?”

>>> print (“learning python”);

> > > print (“learning python”); print("Despa" + 'cito') print(“2” + “2”)
print("Despa" + 'cito') print(“2” + “2”) Error! print (“7” + 8) Son tipos diferentes
print("Despa" + 'cito')
print(“2” + “2”)
Error! print (“7” + 8)
Son tipos diferentes

>>> print (“learning python”);

> > > print (“learning python”); Combine a String with variables nombre = “Alberto” print
Combine a String with variables nombre = “Alberto” print “Hola” %s” % (nombre)
Combine a String with variables
nombre = “Alberto”
print “Hola” %s” % (nombre)

>>> print (“learning python”);

> > > print (“learning python”); ‘My name is “Aina” and I\’m a programmer’ \n =
‘My name is “Aina” and I\’m a programmer’ \n = newline print("""Hello, How are
‘My name is “Aina” and I\’m a programmer’
\n = newline
print("""Hello,
How are you?""")
name is “Aina” and I\’m a programmer’ \n = newline print("""Hello, How are you?""")
name is “Aina” and I\’m a programmer’ \n = newline print("""Hello, How are you?""")
name is “Aina” and I\’m a programmer’ \n = newline print("""Hello, How are you?""")

>>> print (“learning python”);

> > > print (“learning python”); len(str(304023))
len(str(304023))
len(str(304023))
> > > print (“learning python”); len(str(304023))
> > > print (“learning python”); len(str(304023))
> > > print (“learning python”); len(str(304023))

>>> print (“learning python”);

> > > print (“learning python”); Equal to (==) Not equal to (!=) Less than (<)
Equal to (==) Not equal to (!=) Less than (<) Less than or equal to
Equal to (==)
Not equal to (!=)
Less than (<)
Less than or equal to (<=)
Greater than (>)
Greater than or equal to (>=)
= es para asignar!
than (<) Less than or equal to (<=) Greater than (>) Greater than or equal to
than (<) Less than or equal to (<=) Greater than (>) Greater than or equal to
than (<) Less than or equal to (<=) Greater than (>) Greater than or equal to

>>> print (“learning python”);

> > > print (“learning python”);
> > > print (“learning python”);
> > > print (“learning python”);
> > > print (“learning python”);