File tree 1 file changed +63
-0
lines changed
Roadmap/01 - OPERADORES Y ESTRUCTURAS DE CONTROL/python
1 file changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ #Python cuenta con multiples operadores, a continuación se enlistan los diferentes que existen
2
+
3
+ #Operadores numericos
4
+
5
+ suma = 13 + 12
6
+ resta = 45 - 12
7
+ division = 21 / 9
8
+ multiplicacion = 12 * 89
9
+ potencia = 12 ** 12
10
+ division_entera = 45 // 6
11
+ modulo = 12 % 8
12
+
13
+ #Operadores de comparación
14
+ igualdad = 'Hola' == 'Hola'
15
+ mayor_que = 5 > 12 #tambien existe el mayor o igual >=
16
+ menor_que = 6 < 0 #tambien existe el menor o igual <=
17
+ diferente = 'hola' != 'hola'
18
+
19
+ #operadores booleanos
20
+ y_and = True and False
21
+ o_or = (5 > 32 ) or ('perro' != 'gato' )
22
+ no_not = not (True )
23
+
24
+ #Operaciones con strings
25
+ concatenacion = 'Hola' + ' como estas?'
26
+ repeticion = 'hola' * 3 #da 'holaholahola'
27
+
28
+ # condicionales
29
+ a = 89
30
+ b = 12
31
+
32
+ if a > b :
33
+ print (f'El numero { a } es mayor que { b } ' )
34
+ elif b > a :
35
+ print (f'El numero { a } es menor que { b } ' )
36
+ else :
37
+ print ('a y b son iguales' )
38
+
39
+ #Ciclos
40
+
41
+ #Ciclo for
42
+ for i in range (0 ,10 ):
43
+ pass
44
+
45
+ #Ciclo while
46
+ # while True:
47
+ # #Hacer esto
48
+ # pass
49
+
50
+ def operar (a ,b ):
51
+ try :
52
+ operacion = a / b
53
+ print (a / b )
54
+ except ZeroDivisionError :
55
+ print ("No se peude dividir entre cero" )
56
+
57
+ operar (12 ,0 )
58
+
59
+
60
+ # Ejercicio opcional
61
+ for i in range (10 ,56 ):
62
+ if i % 2 == 0 and i != 16 and not (i % 3 == 0 ):
63
+ print (i )
You can’t perform that action at this time.
0 commit comments