Advertisement
teslariu

geom

May 22nd, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. from math import pi, sqrt
  5.  
  6. def leer_dato(dato):
  7.     """Función que lee y devuelve un entero"""
  8.     while True:
  9.         try:
  10.             valor = float(input(f"Por favor, ingrese {dato}: "))
  11.             return valor
  12.         except ValueError:
  13.             print("Error: no ha ingresado un numero")
  14.            
  15.            
  16. def cuadrado(lado):
  17.     return [lado**2, lado*4]
  18.    
  19. def circulo(radio):
  20.     return [pi*radio**2, 2*pi*radio]
  21.    
  22. def triangulo(base, altura):
  23.     return [base*altura/2, base + altura + sqrt(base**2+altura**2)]
  24.    
  25. def imprimir(resultados):
  26.     print("Superficie: {:.2f} - Perímetro: {:.2f}".format(resultados[0],resultados[1]))
  27.            
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement