-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09-caluladora-ejercicio.py
58 lines (40 loc) · 1.26 KB
/
09-caluladora-ejercicio.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
operaciones = ['suma', 'resta', 'multi', 'divid']
print (' Bienvenidos a la caluladora')
print (' para salir escribe \'salir\'')
print ('Las operaciones son', operaciones)
resultado = ''
while True:
if not resultado:
resultado = input('ingrese numero ')
if resultado.lower() == 'salir':
break
resultado = int(resultado)
op = input('Ingresa la operacion ')
if op.lower() == 'salir':
break
n2 = input('ingresa el siguiente numero: ')
if n2.lower() == 'salir':
break
n2 = int(n2)
# Ahora se programa la logica de las sumas
if op.lower() == 'suma':
resultado += n2
#print (resultado)
elif op.lower() == 'resta':
resultado -= n2
#print (resultado)
elif op.lower() == 'multi':
resultado *= n2
# print (resultado) # en lugar de hacer varios print por cada operacion se hace el formateo de string print (f')
elif op.lower() == 'divid':
resultado /= n2
#print (resultado)
else:
print('operacion no valida')
break
print('el resultado es ',f'{resultado}')
# numero = 9
# operacion = ['suma', 'multi', 'resta','divid']
# if numero == True:
# print ('ingrese operacion ')
# if operacion