-
Lenguaje
Python
-
Descripción
Simula el funcionamiento de una calculadora que realiza las operaciones básicas de SUMA, RESTA, MULTIPLICACIÓN y DIVISIÓN. El algoritmo debe mostrar un mensaje de ¿DESEA CONTINUAR[S/N]? El algoritmo se detiene si se presiona la letra [N].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os, msvcrt, sys
tecla_repetir = b's'
while tecla_repetir==b's' or tecla_repetir==b'S':
os.system ('cls')
a = float (input ('Ingresa el valor de a: '))
b = float (input ('Ingresa el valor de b: '))
suma=a+b
resta=a-b
multiplicacion=a*b
if b==0:
division=0
else:
division=a/b
print ('Valor de division: ' + repr (division))
print ('Valor de multiplicacion: ' + repr (multiplicacion))
print ('Valor de resta: ' + repr (resta))
print ('Valor de suma: ' + repr (suma))
print ()
sys.stdout.write ('\u00BFDeseas repetir el proceso? (S/N): ')
tecla_repetir = b'\0'
while tecla_repetir!=b's' and tecla_repetir!=b'S' and tecla_repetir!=b'n' and tecla_repetir!=b'N':
tecla_repetir = msvcrt.getch ()
tecla_repetir = b's'
while tecla_repetir==b's' or tecla_repetir==b'S':
os.system ('cls')
a = float (input ('Ingresa el valor de a: '))
b = float (input ('Ingresa el valor de b: '))
suma=a+b
resta=a-b
multiplicacion=a*b
if b==0:
division=0
else:
division=a/b
print ('Valor de division: ' + repr (division))
print ('Valor de multiplicacion: ' + repr (multiplicacion))
print ('Valor de resta: ' + repr (resta))
print ('Valor de suma: ' + repr (suma))
print ()
sys.stdout.write ('\u00BFDeseas repetir el proceso? (S/N): ')
tecla_repetir = b'\0'
while tecla_repetir!=b's' and tecla_repetir!=b'S' and tecla_repetir!=b'n' and tecla_repetir!=b'N':
tecla_repetir = msvcrt.getch ()