Advertisement
teslariu

menu

May 8th, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Programa que implementa una calculadora con dos numeros
  5.  
  6. print("Calculadora básica")
  7. print("------------------")
  8.  
  9. while True:
  10.    
  11.     print("\nMenu de opciones:")
  12.     print("1. Suma")
  13.     print("2. Resta")
  14.     print("3. Producto")
  15.     print("4. Cociente")
  16.     print("5. Salir")
  17.  
  18.     opcion = input("Elija su opción: ")
  19.    
  20.    
  21.  
  22.     if opcion == "1":
  23.         a = float(input("Ingrese un numero: "))
  24.         b = float(input("Ingrese otro numero: "))
  25.         print(f"La suma es {a+b}")
  26.    
  27.     elif opcion == "2":
  28.         a = float(input("Ingrese un numero: "))
  29.         b = float(input("Ingrese otro numero: "))
  30.         print(f"La resta es {a-b}")
  31.  
  32.     elif opcion == "3":
  33.         a = float(input("Ingrese un numero: "))
  34.         b = float(input("Ingrese otro numero: "))
  35.         print(f"El producto es {a*b}")
  36.  
  37.     elif opcion == "4":
  38.         a = float(input("Ingrese un numero: "))
  39.         b = float(input("Ingrese otro numero: "))
  40.         print(f"El cociente es {a/b}")
  41.        
  42.     elif opcion == "5":
  43.         print("Gracias por usar este programa...")
  44.         break
  45.    
  46.     else:
  47.         print("Opción incorrecta")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement