Advertisement
teslariu

ge

Jul 31st, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. def ingresar(dato):
  5.     while True:
  6.         try:
  7.             numero = float(input(f"Ingrese {dato}: "))
  8.         except ValueError:
  9.             print("Error: debe ingresar un numero")
  10.         else:
  11.             return numero
  12.  
  13. def area_circulo(r):
  14.     """
  15.    Funciòn que devuelve el àrea de un círculo a partir del radio
  16.    """
  17.     from math import pi
  18.     return pi * r**2
  19.  
  20.  
  21. def perimetro_circulo(r):
  22.     return 2 * pi * r
  23.    
  24.  
  25. def area_cuadrado(l):
  26.     return l ** 2
  27.    
  28.  
  29. def perimetro_cuadrado(l):
  30.     return 4 * l
  31.    
  32.  
  33. def area_triangulo(b,h):
  34.     return b * h / 2
  35.    
  36.  
  37. def perimetro_triangulo_rectangulo(c,C):
  38.     from math import sqrt as raiz
  39.     return c + C + raiz(c**2 + C**2)
  40.    
  41. if __name__ == '__main__':
  42.     radio = ingresar("el radio del circulo")
  43.     area = area_circulo(radio)
  44.     print(f"El área del círculo de radio {radio} es {area}")
  45.  
  46.     lado = ingresar("el lado del cuadrado")
  47.     area = area_cuadrado(lado)
  48.     print(f"El área del cuadrado de lado {lado} es {area}")
  49.    
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement