Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Programa que pide dos números y devuelve su suma, resta, producto y
- cociente
- """
- def suma(a,b):
- return a+b
- def resta(a,b):
- return a-b
- def producto(a,b):
- return a*b
- def cociente(a,b):
- return a/b
- print("Programa aritmético")
- while True:
- print("\nMenu de opciones:")
- print("1. Ingreso de datos")
- print("2. Suma")
- print("3. Resta")
- print("4. Multiplicación")
- print("5. Cociente")
- print("6. Salir")
- opcion = input("Seleccione una opcion: ")
- if opcion =="1":
- a = float(input("Ingrese un nro: "))
- b = float(input("Ingrese otro nro: "))
- elif opcion == "2":
- print(f"La suma de {a} y {b} es {suma(a,b)}")
- elif opcion == "3":
- print(resta(a,b))
- elif opcion == "4":
- print(producto(a,b))
- elif opcion == "5":
- print(cociente(a,b))
- elif opcion == "6":
- print("Gracias por utilizar este programa...")
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement