Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- # Script que pide dos numeros y devuelve su cociente
- def ingresar_numero():
- while True:
- try:
- n = float(input(f"Ingrese un número: "))
- except ValueError:
- print("No ha ingresado un número")
- else:
- return n
- def suma(a,b):
- return a + b
- def producto(a,b):
- return a*b
- if __name__ == "__main__":
- print("Script que calcula la suma o el producto de dos nros")
- while True:
- print("""
- Opciones
- 1. Suma
- 2. Producto
- 3. Salir
- """)
- opcion = input("Seleccione una opción: ")
- if opcion == "1":
- a = ingresar_numero()
- b = ingresar_numero()
- print(suma(a,b))
- elif opcion == "2":
- a = ingresar_numero()
- b = ingresar_numero()
- print(producto(a,b))
- elif opcion == "3":
- print("Adios")
- break
- else:
- print("Error, no existe la opción")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement