Advertisement
teslariu

Untitled

Dec 9th, 2020
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Programa que pide dos números y devuelve su suma, resta, producto y
  6. cociente
  7. """
  8. def suma(a,b):
  9.     return a+b
  10.    
  11. def resta(a,b):
  12.     return a-b
  13.    
  14. def producto(a,b):
  15.     return a*b
  16.    
  17. def cociente(a,b):
  18.     return a/b
  19.  
  20.  
  21. print("Programa aritmético")
  22. while True:
  23.     print("\nMenu de opciones:")
  24.     print("1. Ingreso de datos")
  25.     print("2. Suma")
  26.     print("3. Resta")
  27.     print("4. Multiplicación")
  28.     print("5. Cociente")
  29.     print("6. Salir")
  30.     opcion = input("Seleccione una opcion: ")
  31.    
  32.     if opcion =="1":
  33.         a = float(input("Ingrese un nro: "))
  34.         b = float(input("Ingrese otro nro: "))
  35.    
  36.     elif opcion == "2":
  37.         print(f"La suma de {a} y {b} es {suma(a,b)}")
  38.        
  39.     elif opcion == "3":
  40.         print(resta(a,b))
  41.  
  42.     elif opcion == "4":
  43.         print(producto(a,b))
  44.        
  45.     elif opcion == "5":
  46.         print(cociente(a,b))
  47.  
  48.     elif opcion == "6":
  49.         print("Gracias por utilizar este programa...")
  50.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement