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/13 23:32] – [Hola Mundo] 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: [[https:// | 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 ===== | ===== Algunos Conceptos ===== | ||
| Line 60: | Line 60: | ||
| exit() | 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 | Vamos a crear el primer programa en python. Vaya al directorio donde | ||
| Line 86: | Line 92: | ||
| | | ||
| - | ejecute | + | Ejecute |
| python fibonacci.py | python fibonacci.py | ||
| - | Ahora vamos a trabajar con funciones. Recursividad! | + | Como reto. Escriba el programa de manera que se pueda guardar cada término de la serie en una lista. |
| - | emacs factorial.py | + | ====Funciones==== |
| - | # | ||
| - | #este programa utiliza recursividad! para calcular el factorial! | ||
| - | def factorial(n): | + | Ahora vamos a trabajar con funciones. Recursividad! |
| - | if n==0: | + | |
| - | reutrn 1 #factorial de 0 es 1. 0!=1 | + | |
| - | else: | + | emacs factorial.py |
| - | return n*factorial(n-1) # n!= n*(n-1)! | + | |
| - | def main(): | ||
| - | #le solicitamos al usuario un numero al cual calcular el factorial | ||
| - | print " | ||
| - | number=int(raw_input()) | ||
| - | |||
| - | #calculamos el factorial | ||
| - | print str(factorial(number)) | ||
| - | |||
| - | if __name__==" | ||
| - | main() | ||
| Ahora vamos a crear nuestra primera clase | Ahora vamos a crear nuestra primera clase | ||
| - | |||
| - | # | ||
| - | #En este programa creamos una clase | ||
| - | #Numeros complejos | ||
| - | |||
| - | class complex(object): | ||
| - | def __init__(self, | ||
| - | #0 es el numero pro defecto | ||
| - | self.real = real_input | ||
| - | self.img | ||
| - | |||
| - | def get_real_part(self): | ||
| - | return self.real | ||
| - | |||
| - | def get_imaginary_part(self): | ||
| - | return self.img | ||
| - | |||
| - | def get_magnitude(self): | ||
| - | return self.real**2+self.img**2 | ||
| - | |||
| - | def __add__ (self, other): | ||
| - | #se suman self, y other. Ambos complejos | ||
| - | #se reurna un nuevo complejo con el resultado | ||
| - | real_result=self.real+other.get_real_part() | ||
| - | img_result=self.img+other.get_imaginary_part() | ||
| - | |||
| - | return complex(real_result, | ||
| Vamos a utilizar nuestra clase. Corramos python | Vamos a utilizar nuestra clase. Corramos python | ||
tutorials/guia_python.1473809570.txt.gz · Last modified: 2022/09/20 00:08 (external edit)