Skip to content

Commit 052fd42

Browse files
committed
#1 - Python
1 parent a143c00 commit 052fd42

File tree

1 file changed

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

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#operadores aritmeticos
2+
3+
print(f"Suma: 10 + 3 = {10 + 3}")
4+
print(f"Resta: 10 - 3 = {10 - 3}")
5+
print(f"Multiplicacion: 10 * 3 = {10 * 3}")
6+
print(f"Division: 10 / 3 = {10 / 3:2f}")
7+
print(f"Modulos: 10 % 3 = {10 % 3:2f}")
8+
print(f"Exponenciacion: 10 ** 3 = {10**3}")
9+
print(f"Division entera : 10 // 3 = {10 // 3}")
10+
11+
#Operadores de comparacion
12+
print(f"Igualdad: 2 == 3 = {2==3}")
13+
print(f"Desigualdad 2 != 3 = {2!=3}")
14+
print(f"Mayor que: 2 > 3 = {2>3}")
15+
print(f"Menor que: 2 < 3 = {2<3}")
16+
print(f"Moyor o igual que: 2 >= 3 = {2>=3}")
17+
print(f"Menor o igual que: 2 <= 3 = {2<=3}")
18+
19+
# operadores Logicos
20+
print(f"AND: 10 + 3 == 13 and 5 - 1 == 4 es {10+3 == 13 and 5-1 == 4}")
21+
print(f"OR: 10 + 3 == 13 or 5 - 1 == 5 es {10+3 == 13 or 5-1 == 5}")
22+
print(f"NOT: not 10 + 3 == 13 es {not(10+3 == 13)}")
23+
24+
#operadores de asignacion
25+
number = 89
26+
print(number)
27+
number += 1
28+
print(number)
29+
number -= 2
30+
print(number)
31+
number *= 2
32+
print(number)
33+
number /= 2
34+
print(number)
35+
number %= 2
36+
print(number)
37+
number //= 1
38+
print(number)
39+
number **= 1
40+
print(number)
41+
42+
#operadores de identidad
43+
new_number = number
44+
print(f"IS: new_number is number es {new_number is number}")
45+
print(f"IS NOT: new_number is not number es {new_number is not number}")
46+
47+
#operadores de menbresia
48+
print(f"IN: 'j' in 'julian' = {'j' in 'julian'}")
49+
print(f"NOT IN: 'y' not in 'julian' = {'y' not in 'julian'}")
50+
51+
#Operadores de Bit
52+
a = 10 # 1010
53+
b = 3 # 0011
54+
print(f"AND: 10 & 3 = {10 & 3}") # Establece cada bit en 1 si ambos bits son 1 0010 = 2
55+
print(f"OR: 10 | 3 = {10 | 3}") # Establece cada bit en 1 si uno de los dos bits es 1 1011 = 11
56+
print(f"XOR: 10 ^ 3 = {10 ^ 3}") # Establece cada bit en 1 si solo uno de los dos bits es 1 1001 = 9
57+
58+
#Estructuras de control
59+
60+
# if, elif y else
61+
edad = 15
62+
if edad >= 30:
63+
print("Puede ver la pelicula con descuento")
64+
elif edad >= 18:
65+
print("Puede ver la pelicula")
66+
else:
67+
print("No puede ingresar")
68+
69+
# For
70+
buscar = 4
71+
for numero in range(5):
72+
print(numero)
73+
if numero == buscar:
74+
print (f"Encontre el numero {buscar}")
75+
break
76+
else:
77+
print(f"No encontre el numero {buscar}")
78+
79+
#while
80+
numero = 1
81+
while numero < 10:
82+
print(numero)
83+
numero +=1
84+
# ejercicio
85+
c = 10
86+
while c < 56:
87+
if (c % 2 == 0 and c != 16 and c % 3 != 0):
88+
print(c)
89+
c +=1

0 commit comments

Comments
 (0)