100% found this document useful (1 vote)
70 views

Introducción A Python

Pequeña presentación de introducción al lenguaje de programación Python, parte de la asignatura TIC para 4º de ESO

Uploaded by

ainafonolleres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
70 views

Introducción A Python

Pequeña presentación de introducción al lenguaje de programación Python, parte de la asignatura TIC para 4º de ESO

Uploaded by

ainafonolleres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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


>>> introduction to Python

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

High-level, open, multiplatform programming language.


Simple 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
#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))
>>> print (“learning python”);

We need an interpreter to run scripts


Editor vs console

In console: type python3


>>>
https://codeanywhere.com
>>> print (“learning python”);

string = “hola” (cadena de caracteres)


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

print (“hello world!)


print(2 + 2)

#Comment in one single line

Strings and integers are built-in types


>>> print (“learning python”);

Read them!

SyntaxError (something misspelled)


NameError (undefined/unknown variable)
IndexError(when accessing lists)
>>> print (“learning python”);
>>> print (“learning python”);

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”);

To create formulas to use with different values

side = 2
area = side * side
print (area)
>>> print (“learning python”);

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
>>> print (“learning python”);

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

nombre = "Aina"
edad = "35"
comida = "brownie"

‘My name\’s “Aina” and I\’m a programmer’


>>> print (“learning python”);

message = “””Message
in three
lines”””

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

primera_letra = “AINA”[0]

“hello” + “world”
‘hello’ * 3
‘My name is “Aina”’
>>> print (“learning python”);

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

print("Despa" + 'cito')
print(“2” + “2”)

Error! print (“7” + 8) Son tipos diferentes


>>> print (“learning python”);

Combine a String with variables

nombre = “Alberto”
print “Hola” %s” % (nombre)
>>> print (“learning python”);

‘My name is “Aina” and I\’m a programmer’


\n = newline

print("""Hello,
How are you?""")
>>> print (“learning python”);

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

Equal to (==) = es para asignar!


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

You might also like