Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- """
- Módulo que implementa una calculadora que pide dos nros y devuelve
- el resultado de las 4 operaciones básicos entre ellos
- """
- def ingresar_numero():
- while True:
- try:
- numero = float(input("Ingrese un número: "))
- except ValueError:
- print("Error, debe ingresar un número")
- else:
- return numero
- 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):
- if b != 0:
- return a / b
- else:
- raise ZeroDivisionError
- if __name__ == "__main__":
- a = ingresar_numero()
- b = ingresar_numero()
- print(f"{a} + {b} = {a+b}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement