Skip to content

Commit 9d18f82

Browse files
committed
#1-Python
1 parent 6abb448 commit 9d18f82

File tree

1 file changed

+115
-0
lines changed
  • Roadmap/01 - OPERADORES Y ESTRUCTURAS DE CONTROL/python

1 file changed

+115
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Name: Liliana N. Torres Rignack
2+
3+
# EJERCICIO
4+
5+
# OPERADORES ARITMETICOS
6+
print("--> OPERADORES ARITMETICOS <--")
7+
8+
my_sum = 10 + 9
9+
print(my_sum)
10+
11+
my_rest = 10 - 9
12+
print(my_rest)
13+
14+
my_multiplication = 79 * 45
15+
print(my_multiplication)
16+
17+
my_division = 189 / 4
18+
print(my_division)
19+
20+
modulo_operator = 20 % 2
21+
print(modulo_operator)
22+
23+
my_floor_division = 256 // 3
24+
print(my_floor_division)
25+
26+
my_exponent = 2**6
27+
print(my_exponent)
28+
29+
# OPERADORES DE COMPARACION
30+
print("--> OPERADORES DE ASIGNACION <--")
31+
print(2 == 2) # True
32+
print("A" != "a") # True
33+
print(25 > 30) # False
34+
print(23456 < 23658) # True
35+
print(10 >= 10) # True
36+
print(5 <= 6) # True
37+
38+
# OPERADORES LOGICOS
39+
print("--> OPERADORES LOGICOS <--")
40+
print(f"False and False --> {False and False}") # False
41+
print(f"True or False --> {True or False}") # True
42+
print(f"not True --> {not True}") # False
43+
44+
# OPERADORES DE ASIGNACION
45+
my_name = "Liliana" # Asignacion simple
46+
my_num: int = 2
47+
my_num += 4 # my_num = 6
48+
my_num -= 1 # my_num = 5
49+
my_num *= 5 # my_num = 25
50+
my_num /= 5 # my_num = 5
51+
52+
# BITS
53+
print("--> BITS <--")
54+
x = 4
55+
y = 5
56+
print(f"AND bit a bit --> {x & y}")
57+
print(f"OR bit a bit --> {x | y}")
58+
print(f"XOR bit a bit --> {x ^ y}")
59+
print(f"Complemento bit a bit --> {x} --> {~x}")
60+
print(f"Desplazamiento a la izquierda {x << 1}")
61+
print(f"Desplazamiento a la derecha {x >> 1}")
62+
63+
# OPERADORES DE IDENTIDAD
64+
print("--> OPERADORES DE IDENTIDAD <--")
65+
variable_1: str = "Variable"
66+
variable_2: str = "variable"
67+
print(variable_1 is variable_2) # False
68+
print(variable_1 is not variable_2) # True
69+
70+
# OPERADORES DE PERTENENCIA
71+
print("--> OPERADORES DE PERTENENCIA <--")
72+
my_list = [10, 20, 30, 40, 50]
73+
print(25 in my_list) # False
74+
print(40 not in my_list) # False
75+
76+
# ESTRUCTURAS DE CONTROL
77+
78+
print("--> CONDICIONAL <--")
79+
# Condicionales
80+
var = 10
81+
if var < 12:
82+
print("Less than 12")
83+
elif var > 12:
84+
print("Greater than 12")
85+
else:
86+
print("Equals to 12")
87+
88+
print("--> WHILE LOOP <--")
89+
# Bucles while
90+
var = 1
91+
while var <= 5:
92+
print(var)
93+
var += 1
94+
95+
print("--> FOR LOOP <--")
96+
# Bucles for
97+
for _ in range(6):
98+
print("This is a for loop!")
99+
100+
print("--> TRY / EXCEPT <--")
101+
# Excepciones
102+
try:
103+
print("Trying")
104+
except ValueError:
105+
print("Cannot do this")
106+
107+
print("--> EXTRA <--")
108+
# DIFICULTAD EXTRA
109+
def numbers(a, b):
110+
for number in range(a, b + 1, 2):
111+
if number is not 16 and number % 3 != 0:
112+
print(number)
113+
114+
numbers(10, 55)
115+

0 commit comments

Comments
 (0)