User Tools

Site Tools


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.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:guia_python [2016/09/13 23:29] – [Temas] dgarciatutorials: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://learnpythonthehardway.org/book/|Learn Python The Hard Way]].+Ejercicios tomados de [[http://learnpythonthehardway.org/python3/|Learn Python The Hard Way]].
  
 Para conocer algunos conceptos básicos previos, puede visitar: [[https://en.wikiversity.org/wiki/Introduction_to_Programming/About_Programming]] Para conocer algunos conceptos básicos previos, puede visitar: [[https://en.wikiversity.org/wiki/Introduction_to_Programming/About_Programming]]
 ===== Ejercicios sugeridos: ===== ===== Ejercicios sugeridos: =====
  
-  - [[http://learnpythonthehardway.org/book/ex0.html|Instalación del ambiente]] +  - [[http://learnpythonthehardway.org/python3/ex0.html|Instalación del ambiente]] 
-  - [[http://learnpythonthehardway.org/book/ex1.html|Primer programa]] +  - [[http://learnpythonthehardway.org/python3/ex1.html|Primer programa]] 
-  - [[http://learnpythonthehardway.org/book/ex2.html|Comentarios]] +  - [[http://learnpythonthehardway.org/python3/ex2.html|Comentarios]] 
-  - [[http://learnpythonthehardway.org/book/ex3.html|Operaciones matemáticas]] +  - [[http://learnpythonthehardway.org/python3/ex3.html|Operaciones matemáticas]] 
-  - [[http://learnpythonthehardway.org/book/ex4.html|Variables]] +  - [[http://learnpythonthehardway.org/python3/ex4.html|Variables]] 
-  - [[http://learnpythonthehardway.org/book/ex5.html|Variables e impresión]] +  - [[http://learnpythonthehardway.org/python3/ex5.html|Variables e impresión]] 
-  - [[http://learnpythonthehardway.org/book/ex13.html|Paramétros e imports]] +  - [[http://learnpythonthehardway.org/python3/ex13.html|Paramétros e imports]] 
-  - [[http://learnpythonthehardway.org/book/ex14.html|Uso de parámetros]] +  - [[http://learnpythonthehardway.org/python3/ex14.html|Uso de parámetros]] 
-  - [[http://learnpythonthehardway.org/book/ex18.html|Funciones]] +  - [[http://learnpythonthehardway.org/python3/ex18.html|Funciones]] 
-  - [[http://learnpythonthehardway.org/book/ex19.html|Funciones y variables]] +  - [[http://learnpythonthehardway.org/python3/ex19.html|Funciones y variables]] 
-  - [[http://learnpythonthehardway.org/book/ex25.html|Imports de código creado]] +  - [[http://learnpythonthehardway.org/python3/ex25.html|Imports de código creado]] 
-  - [[http://learnpythonthehardway.org/book/ex26.html|Código ajeno]] +  - [[http://learnpythonthehardway.org/python3/ex26.html|Código ajeno]] 
-  - [[http://learnpythonthehardway.org/book/ex27.html|Introducción a la lógica]] +  - [[http://learnpythonthehardway.org/python3/ex27.html|Introducción a la lógica]] 
-  - [[http://learnpythonthehardway.org/book/ex28.html|Práctica de lógica]] +  - [[http://learnpythonthehardway.org/python3/ex28.html|Práctica de lógica]] 
-  - [[http://learnpythonthehardway.org/book/ex29.html|If]] +  - [[http://learnpythonthehardway.org/python3/ex29.html|If]] 
-  - [[http://learnpythonthehardway.org/book/ex30.html|Else]] +  - [[http://learnpythonthehardway.org/python3/ex30.html|Else]] 
-  - [[http://learnpythonthehardway.org/book/ex31.html|Uso de If y Else]] +  - [[http://learnpythonthehardway.org/python3/ex31.html|Uso de If y Else]] 
-  - [[http://learnpythonthehardway.org/book/ex32.html|Ciclos]] +  - [[http://learnpythonthehardway.org/python3/ex32.html|Ciclos]] 
-  - [[http://learnpythonthehardway.org/book/ex33.html|While]]+  - [[http://learnpythonthehardway.org/python3/ex33.html|While]]
  
 ===== Ejercicios extras: ===== ===== Ejercicios extras: =====
  
-  * [[http://learnpythonthehardway.org/book/ex34.html|Listas]] +  * [[http://learnpythonthehardway.org/python3/ex34.html|Listas]] 
-  * [[http://learnpythonthehardway.org/book/ex38.html|Trabajando con listas]] +  * [[http://learnpythonthehardway.org/python3/ex38.html|Trabajando con listas]] 
-  * [[http://learnpythonthehardway.org/book/ex39.html|Diccionarios]]+  * [[http://learnpythonthehardway.org/python3/ex39.html|Diccionarios]]
  
 ===== 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://github.com/degv364/capacitaciones_python.git
 +
 +==== 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 69: Line 75:
  
   #!/usr/bin/env python   #!/usr/bin/env python
- 
   #imprimir los primeros 100 terminos no triviales de la   #imprimir los primeros 100 terminos no triviales de la
   #serie de Fibonacci   #serie de Fibonacci
- 
   def main():   def main():
       #creamos la variable inicial       #creamos la variable inicial
       finonacci_last=1       finonacci_last=1
       fibonacci_last_last=1       fibonacci_last_last=1
- 
       for i in range(100):       for i in range(100):
         #creamos el nuevo termino de laserie         #creamos el nuevo termino de laserie
    fibonacci_current=fibonacci_last+fibonacci_last_last    fibonacci_current=fibonacci_last+fibonacci_last_last
- 
    #hacemos update de los 'last'    #hacemos update de los 'last'
    fibonacci_last=fibonacci_current    fibonacci_last=fibonacci_current
    fibonacci_last_last=fibonacci_last    fibonacci_last_last=fibonacci_last
- 
    #imprimir el resultado    #imprimir el resultado
    print fibonacci_current    print fibonacci_current
- 
   if __name__=="__main__":   if __name__=="__main__":
      main()      main()
  
-ejecute el programa anterior de la siguiente manera:+Ejecute el programa anterior de la siguiente manera:
  
   python fibonacci.py   python fibonacci.py
  
-Ahora vamos a trabajar con funcionesRecursividad!+Como reto. Escriba el programa de manera que se pueda guardar cada término de la serie en una lista.
  
-  emacs factorial.py+====Funciones====
  
  
-  #!/usr/bin/env python 
-  #este programa utiliza recursividad! para calcular el factorial! 
  
-  def factorial(n): +Ahora vamos a trabajar con funcionesRecursividad!
-      if n==0: +
-      reutrn 1 #factorial de 0 es 10!=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 "Estimado usuario, digite un entero" 
-      number=int(raw_input()) 
- 
-      #calculamos el factorial 
-      print str(factorial(number)) 
- 
-  if __name__=="__main__": 
-      main() 
  
 Ahora vamos a crear nuestra primera clase Ahora vamos a crear nuestra primera clase
- 
-  #!/usr/bin/env python 
-  #En este programa creamos una clase 
-  #Numeros complejos 
- 
-  class complex(object): 
-  def __init__(self, real_input=0, img_input=0): #metodo contructor 
- #0 es el numero pro defecto 
- self.real = real_input 
- self.img  = img_input 
- 
-        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, img_result) 
  
 Vamos a utilizar nuestra clase. Corramos python Vamos a utilizar nuestra clase. Corramos python
tutorials/guia_python.1473809391.txt.gz · Last modified: 2022/09/20 00:08 (external edit)