Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- def ingresar(dato):
- while True:
- try:
- numero = float(input(f"Ingrese {dato}: "))
- except ValueError:
- print("Error: debe ingresar un numero")
- else:
- return numero
- def area_circulo(r):
- """
- Funciòn que devuelve el àrea de un círculo a partir del radio
- """
- from math import pi
- return pi * r**2
- def perimetro_circulo(r):
- return 2 * pi * r
- def area_cuadrado(l):
- return l ** 2
- def perimetro_cuadrado(l):
- return 4 * l
- def area_triangulo(b,h):
- return b * h / 2
- def perimetro_triangulo_rectangulo(c,C):
- from math import sqrt as raiz
- return c + C + raiz(c**2 + C**2)
- if __name__ == '__main__':
- radio = ingresar("el radio del circulo")
- area = area_circulo(radio)
- print(f"El área del círculo de radio {radio} es {area}")
- lado = ingresar("el lado del cuadrado")
- area = area_cuadrado(lado)
- print(f"El área del cuadrado de lado {lado} es {area}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement