Advertisement
knomo

Semana4-CuatroOperaciones

Jun 3rd, 2023
963
0
58 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | Source Code | 0 0
  1. def suma(a, b): return a + b
  2. def resta(a, b): return a - b
  3. def multiplica(a, b): return a * b
  4. def divide(a, b): return a / b
  5. def sale(): print("ADIOS!")
  6.  
  7. print("Cuatro operaciones")
  8. print("1. Sumar")
  9. print("2. Restar")
  10. print("3. Multiplicar")
  11. print("4. Dividir")
  12. print("5. Salir")
  13.  
  14. print("Ingrese el primer valor: ")
  15. a = int(input())
  16. print("Ingrese el segundo valor: ")
  17. b = int(input())
  18. print("Los valores ingresados son: " + str(a) + " y " + str(b))
  19. opcion = 0
  20.  
  21. while(opcion != 5):
  22.     print("Por favor ingrese opción: ")
  23.     opcion = int(input())
  24.     print("Opción ingresada : " + str(opcion))
  25.     if(opcion == 1): print("la suma es: ", suma(a,b))
  26.     elif(opcion == 2): print("la resta es: ", resta(a,b))
  27.     elif(opcion == 3): print("la multiplicación es: ", multiplica(a,b))
  28.     elif(opcion == 4): print("la división es: ", divide(a,b))
  29.     elif(opcion == 5): sale()
  30.     else: print("Opción inválida")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement