1
+ # #01 - Python -> Jesus Antonio Escamilla
2
+
3
+ """
4
+ EJERCIÓ
5
+ """
6
+
7
+ """
8
+ Operaciones
9
+ """
10
+ '''
11
+ ARITMÉTICA
12
+ '''
13
+ print (f"Suma: 3 + 5 = { 3 + 5 } " )
14
+ print (f"Resta: 6 - 4 = { 6 - 4 } " )
15
+ print (f"Multiplicación: 5 * 2 = { 5 * 2 } " )
16
+ print (f"Division: 10 / 1 = { 10 / 1 } " )
17
+ print (f"Division Entera: 10 // 2= { 10 // 2 } " )
18
+ print (f"Modulo: 8 % 2 = { 8 % 2 } " )
19
+ print (f"Exponente: 4 ** 2 = { 4 ** 2 } " )
20
+
21
+ '''
22
+ ASIGNACIÓN
23
+ '''
24
+ number = 5
25
+ print (f"Asignación { number } " )
26
+ number += 2
27
+ print (f"Asignación y Suma { number } " )
28
+ number -= 1
29
+ print (f"Asignación y Resta { number } " )
30
+ number *= 7
31
+ print (f"Asignación y Multiplicación { number } " )
32
+ number /= 3
33
+ print (f"Asignación y Division { number } " )
34
+ number //= 3
35
+ print (f"Asignación y Division Entera { number } " )
36
+ number %= 6
37
+ print (f"Asignación y Modulo { number } " )
38
+ number **= 3
39
+ print (f"Asignación y Exponente { number } " )
40
+
41
+ '''
42
+ COMPARACIÓN
43
+ '''
44
+ print (f"Igualdad: 10 == 3 -> { 10 == 3 } " )
45
+ print (f"Distinto: 2 != 1 -> { 2 != 1 } " )
46
+ print (f"Mayor que: 5 > 4 -> { 5 > 4 } " )
47
+ print (f"Menor que: 8 < 11 -> { 8 < 11 } " )
48
+ print (f"Mayor que o igual: 7 >= 6 -> { 7 >= 6 } " )
49
+ print (f"Menor que o igual: 9 <= 4 -> { 9 <= 4 } " )
50
+
51
+ '''
52
+ LÓGICOS
53
+ '''
54
+ print (f"AND - &&: 10 == 10 and 5 == 6 { 10 == 10 and 5 == 6 } " )
55
+ print (f"OR - ||: 7 == 3 or 3 == 3 { 7 == 3 or 3 == 3 } " )
56
+ print (f"NOT - !: not 2 == 4 { not 2 == 4 } " )
57
+
58
+ '''
59
+ IDENTIDAD
60
+ '''
61
+ new_number = number
62
+ print (f"new_number is number: { new_number is number } " )
63
+ print (f"new_number is not number: { new_number is not number } " )
64
+
65
+ '''
66
+ BITS
67
+ '''
68
+ a = 10 # 1010 en binario
69
+ b = 4 # 0100 en binario
70
+
71
+ print (f"AND: a & b: { a & b } " )
72
+ print (f"OR: a | b: { a | b } " )
73
+ print (f"XOR: a ^ b: { a ^ b } " )
74
+ print (f"NOT: a & b: { ~ a } " )
75
+ print (f"Desplazamiento a la izquierda: a & b: { a << b } " )
76
+ print (f"Desplazamiento a la derecha: a & b: { a >> b } " )
77
+
78
+
79
+ """
80
+ Estructura de Control
81
+ """
82
+ '''
83
+ IF-ELIF-ELSE
84
+ '''
85
+ x = 10
86
+ if x > 0 :
87
+ print ("Es positivo" )
88
+ elif x == 0 :
89
+ print ("Es cero" )
90
+ else :
91
+ print ("Es Negativo" )
92
+
93
+ '''
94
+ FOR
95
+ '''
96
+ frutas = ["Manzana" , "Pera" , "Cereza" ]
97
+ for fruta in frutas :
98
+ print (fruta )
99
+
100
+ for i in range (5 ):
101
+ print (i )
102
+
103
+
104
+ '''
105
+ WHILE
106
+ '''
107
+ i = 0
108
+ while i < 5 :
109
+ print (i )
110
+ i += 1
111
+
112
+
113
+ '''
114
+ TRY-EXCEPT-FINALLY
115
+ '''
116
+ try :
117
+ resultado = 10 / 0
118
+ except :
119
+ print ("No se puede dividir entre 0" )
120
+ finally :
121
+ print ("Fin del bloque try-except" )
122
+
123
+
124
+ """
125
+ EXTRA
126
+ """
127
+ #Pendiente
0 commit comments