Apunte Python I
Apunte Python I
Programador Universitario
Licenciatura en informática
FACET-UNT
2022
https://www.python.org
El intérprete estándar incluye un modo interactivo
(intérprete de comandos)
❖ Las expresiones pueden ser introducidas una a una para ver el resultado de su
evaluación inmediatamente.
>>> 1 + 1
2
>>> a = range(10)
>>> print a
[0,1, 2, 3, 4, 5, 6, 7, 8, 9]
SINTAXIS
Comentarios
detrás de # o triple comillas
Asignación
se usa =
Ej:
❖ Puede tomar distintos valores en otro momento, incluso de un tipo diferente al que
tenía previamente.
>>> x = 1
>>> x = "texto" # Esto es posible porque los tipos son asignados dinámicamente
TIPOS DE DATOS
Números :
- Integer
- Float
- Complejos
Cadenas
Tuplas
Listas
SINTAXIS
Estructuras de control
IF WHILE
while condicion:
if condicion:
acciones
acciones
elif condicion:
acciones And or not
else:
acciones True False
FOR
import math as m
figure(num = None, figsize = (8, 6), dpi = 80, facecolor = 'w', edgecolor = 'k')
subplot(numRows, numCols, plotNum):Permite incluir varias gráficas en una única
figura.
plot(x, y, linestyle, linewidth, marker):Permite incluir varias gráficas en una única
figura. Tanto x como y pueden ser abcisas tuplas, listas o arrays. La única condición es
que el tamaño de ambas debe ser el mismo ya que en caso contrario python nos
devolverá un fallo de tipo dimesión.
show(): Presenta las figuras en pantalla.
xlabel(‘s’, comandos_optativos): Etiqueta el eje X
ylabel(‘s’, comandos_optativos): Etiqueta el eje Y
title(‘s’, comandos_optativos): Coloca un titulo a la gráfica
axis() Establece u obtiene las propiedades de los ejes
FUNCIONES
def nombrefunción(arg1,arg2..):
instrucción_1
instrucción_2
.................
instrucción_N
return ….
❖ http://lsi.ugr.es/~pdo/Seminarios/Python2005.pdf
❖ http://wp.df.uba.ar/wtpc/wp-
content/uploads/sites/6/2016/03/02_basico_python_jarne.pdf
❖ http://pendientedemigracion.ucm.es/info/aocg/python/modulos_
cientificos/numpy/index.html
❖ http://pendientedemigracion.ucm.es/info/aocg/python/modulos_
cientificos/matplotlib/index.html
❖ https://docs.python.org/2/library/math.html#math.sqrt