-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathejemplo.py
More file actions
79 lines (61 loc) · 1.21 KB
/
ejemplo.py
File metadata and controls
79 lines (61 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Ejemplo python
#############################
# Carga de librerias
#############################
import math as m
from random import shuffle
#############################
# 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))