1
+ """
2
+ * Operadores
3
+ """
4
+
5
+ # Aritmeticos
6
+
7
+ print (f"Addition: 18 + 8 = { 18 + 8 } " )
8
+ print (f"Subtraction: 18 - 8 = { 18 - 8 } " )
9
+ print (f"Multiplication: 18 * 8 = { 18 * 8 } " )
10
+ print (f"Division: 18 / 8 = { 18 / 8 } " )
11
+ print (f"Modulus: 18 % 8 = { 18 % 8 } " )
12
+ print (f"Floor division: 18 // 8 = { 18 // 8 } " )
13
+ print (f"Exponentiation: 18 ** 8 = { 18 ** 8 } " )
14
+
15
+ # Logicos (and or not)
16
+
17
+ print (True == True and False == False )
18
+ print (False == True or False == False )
19
+ print (not True )
20
+
21
+ # Comparacion
22
+
23
+ print (f"Greater than: 24 > 24 = { 24 > 24 } " )
24
+ print (f"Less than: 24 < 24 = { 24 < 24 } " )
25
+ print (f"Greater than or equal to: 24 >= 24 = { 24 >= 24 } " )
26
+ print (f"Less than or equal to: 24 <= 24 = { 24 <= 24 } " )
27
+ print (f"Equal: 24 == 24 = { 24 == 24 } " )
28
+ print (f"Not equal: 24 != 24 = { 24 != 24 } " )
29
+
30
+ # Asignacion
31
+
32
+ number = 24
33
+
34
+ number += 2
35
+ print (number )
36
+ number -= 3
37
+ print (number )
38
+ number *= 1
39
+ print (number )
40
+ number /= 5
41
+ print (number )
42
+ number %= 5
43
+ print (number )
44
+ number //= 1
45
+ print (number )
46
+ number **= 4
47
+ print (number )
48
+
49
+ # Identidad
50
+
51
+ variable = None
52
+
53
+ print (f"My variable is None: { variable is None } " )
54
+ print (f"My variable is not None: { variable is not None } " )
55
+
56
+ # Pertenencia
57
+
58
+ print (f"'E' in word: { "E" in "word" } " )
59
+ print (f"'E' not in word: { "E" not in "word" } " )
60
+
61
+ # Bits
62
+
63
+ a = 8 # 1000
64
+ b = 10 # 1010
65
+
66
+ print (f"AND: 8 & 10 = { 8 & 10 } " ) # 0001 <
67
+ print (f"OR: 8 | 10 = { 8 | 10 } " ) # 0101 <
68
+ print (f"XOR: 8 ^ 10 = { 8 ^ 10 } " ) # 0100 <
69
+ print (f"NOT: ~8 = { ~ 8 } " )
70
+ print (f"Right shift: 8 >> 10: { 8 >> 2 } " ) # 0010
71
+ print (f"Left shift: 8 << 10: { 8 << 2 } " ) # 100000
72
+
73
+ """
74
+ * Estructuras de control
75
+ """
76
+
77
+ # Condicionales
78
+
79
+ language = "Python"
80
+
81
+ if language == "JavaScript" :
82
+ print ("The language is JavaScript" )
83
+ elif language == "Python" :
84
+ print ("The language is Python" )
85
+ else :
86
+ print ("It could be another language" )
87
+
88
+ # Iterativas
89
+
90
+ for number in range (1 , 9 ):
91
+ print (number )
92
+
93
+ age = 0
94
+
95
+ while age <= 8 :
96
+ print (age )
97
+ age += 2
98
+
99
+ # Excepciones
100
+
101
+ try :
102
+ print (18 / 0 )
103
+ except :
104
+ print ("Division by zero?" ) # ZeroDivisionError
105
+ finally :
106
+ print ("Bye!" )
107
+
108
+ """
109
+ * Extra
110
+ """
111
+
112
+ for extra_number in range (10 , 56 ):
113
+ if extra_number % 2 == 0 and extra_number != 16 and extra_number % 3 != 0 :
114
+ print (extra_number )
0 commit comments