Skip to content

Añado python tutorial #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tutorial de Python

Tutorial para python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creo que deberíamos especificar que es Python 3

79 changes: 79 additions & 0 deletions python/ejemplo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Ejemplo python

#############################
# Carga de librerias
#############################
import math as m
from random import shuffle
Comment on lines +6 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí importas dos librerías que luego no usas. ¿Quizá estaría bien usar alguna de las funciones que se importan como ejemplo?


#############################
# Asignaciones
#############################
var1 = "hola"
var2 = 7
var3 = var2
var1 = "otra cosa"

#############################
# Tipos de datos
#############################

# Numeros
n1 = 3
n2 = 3.23

# Booleanos
b1 = 3 != 2
b2 = False

# Strings
var = "mensaje"

# Listas
lis = [1, 2, 3, "cosa"]
lis2 = lis[0:1]
lis3 = [x ** 2 for x in range(3)]

# Diccionarios
dic = {"tomate":"fresco", "lechuga":"mala"}
dic["nuevo"] = "cosa"
print(dic["nuevo"])

# Conjuntos
set = {"huevos", "leche", "mantequilla"}

# Tuplas
tup = (3, 2)
trip = (3, "cosa", 3.2)


#############################
## Bucles, control
#############################

arr = [1, 2, 3]
for item in arr:
print(item)
for i in range(len(arr)):
print(arr[i])

i = 0
while i < len(arr):
print(arr[i])
i += 1

if 0 != 0:
print("Mates rotas")
elif 0 == 0:
print("Todo bien de momento")
else:
print("Imposible de llegar!!!")

#############################
## Funciones
#############################

def nueva_func(par1, par2):
return par1 + par2

print(nueva_func(1, 2))