Writing /var/lib/dokuwiki/data/meta/tutorials/guia_python.meta failed
tutorials:guia_python
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:guia_python [2016/09/08 22:52] – [Guía Python] dgarcia | tutorials:guia_python [2022/09/20 00:08] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| Guía para aprender conceptos básicos de programación junto al lenguaje de programación Python. | Guía para aprender conceptos básicos de programación junto al lenguaje de programación Python. | ||
| - | Ejercicios tomados de [[http:// | + | Ejercicios tomados de [[http:// |
| - | Para conocer algunos conceptos básicos previos, puede visitar | + | Para conocer algunos conceptos básicos previos, puede visitar: [[https:// |
| ===== Ejercicios sugeridos: ===== | ===== Ejercicios sugeridos: ===== | ||
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| - | - [[http:// | + | - [[http:// |
| ===== Ejercicios extras: ===== | ===== Ejercicios extras: ===== | ||
| - | * [[http:// | + | * [[http:// |
| - | * [[http:// | + | * [[http:// |
| - | * [[http:// | + | * [[http:// |
| + | ===== Algunos Conceptos ===== | ||
| + | |||
| + | =====Temas===== | ||
| + | |||
| + | * Hola mundo | ||
| + | * Variable e imprimir | ||
| + | * Funcion | ||
| + | * Clase | ||
| + | * Import | ||
| + | |||
| + | |||
| + | ====Hola Mundo==== | ||
| + | |||
| + | Abra una terminal y ejecute python. Se va a abrir un interpretador de python. | ||
| + | |||
| + | print "Hola Mundo" | ||
| + | variable_a_imprimir=" | ||
| + | print variable_a_imprimir | ||
| + | a=2 | ||
| + | b=3 | ||
| + | c=a+b | ||
| + | print c | ||
| + | print 2**100 | ||
| + | |||
| + | Ahora para salir del interprete de python ejecute el siguiente comando: | ||
| + | |||
| + | exit() | ||
| + | |||
| + | Vamos a clonar el material con el que se va a estar trabajando. | ||
| + | |||
| + | git clone https:// | ||
| + | |||
| + | ==== Loops, variables, listas==== | ||
| + | |||
| + | Vamos a crear el primer programa en python. Vaya al directorio donde | ||
| + | quiere tener su programa. | ||
| + | |||
| + | emacs fibonacci.py | ||
| + | |||
| + | Esto va a abrir emacs para poder editar su programa. | ||
| + | |||
| + | # | ||
| + | #imprimir los primeros 100 terminos no triviales de la | ||
| + | #serie de Fibonacci | ||
| + | def main(): | ||
| + | #creamos la variable inicial | ||
| + | finonacci_last=1 | ||
| + | fibonacci_last_last=1 | ||
| + | for i in range(100): | ||
| + | #creamos el nuevo termino de laserie | ||
| + | fibonacci_current=fibonacci_last+fibonacci_last_last | ||
| + | #hacemos update de los ' | ||
| + | fibonacci_last=fibonacci_current | ||
| + | fibonacci_last_last=fibonacci_last | ||
| + | #imprimir el resultado | ||
| + | print fibonacci_current | ||
| + | if __name__==" | ||
| + | | ||
| + | |||
| + | Ejecute el programa anterior de la siguiente manera: | ||
| + | |||
| + | python fibonacci.py | ||
| + | |||
| + | Como reto. Escriba el programa de manera que se pueda guardar cada término de la serie en una lista. | ||
| + | |||
| + | ====Funciones==== | ||
| + | |||
| + | |||
| + | |||
| + | Ahora vamos a trabajar con funciones. Recursividad! | ||
| + | |||
| + | emacs factorial.py | ||
| + | |||
| + | |||
| + | Ahora vamos a crear nuestra primera clase | ||
| + | |||
| + | Vamos a utilizar nuestra clase. Corramos python | ||
| + | |||
| + | python | ||
| + | |||
| + | number1=complex(1, | ||
| + | number2=complex(42, | ||
| + | number1.get_real_part() | ||
| + | number2.get_imaginary_part() | ||
| + | result=number1+number2 | ||
| + | print str(result.get_real_part())+ " + i" + str(result.get_imaginary_part()) | ||
| + | ===== Estilos ===== | ||
| + | En el Arcos-Lab sugerimos seguir la siguiente [[https:// | ||
tutorials/guia_python.1473375175.txt.gz · Last modified: 2022/09/20 00:08 (external edit)