Advertisement
teslariu

aritmetica.py

Mar 27th, 2021
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. """
  5. Módulo que implementa  una calculadora que pide dos nros y devuelve
  6. el resultado de las 4 operaciones básicos y la raiz cuadrada de cada
  7. uno de ellos
  8. """
  9.  
  10. def ingresar_numero():
  11.     while True:
  12.         try:
  13.             numero = float(input("Ingrese un número: "))
  14.         except ValueError:
  15.             print("Error, debe ingresar un número")
  16.         else:
  17.             return numero
  18.            
  19. def suma(a,b):
  20.     return a + b
  21.    
  22. def resta(a,b):
  23.     return a - b
  24.    
  25. def producto(a,b):
  26.     return a * b
  27.    
  28. def cociente(a,b):
  29.     if b != 0:
  30.         return a / b
  31.     else:
  32.         raise ZeroDivisionError
  33.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement