Skip to content

Instantly share code, notes, and snippets.

@IanCarloz
Created April 7, 2017 01:39
Show Gist options
  • Save IanCarloz/54305aaaa4ea1ae3b222669f7bbf3410 to your computer and use it in GitHub Desktop.
Save IanCarloz/54305aaaa4ea1ae3b222669f7bbf3410 to your computer and use it in GitHub Desktop.
class Figura:
def __init__(self, name, height, width):
self.name = name
self.height = height
self.width = width
def area(self):
area = self.height * self.width
print('a=', area)
def perimetro(self):
perimetro = self.height * 2 + self.width * 2
print('p=', perimetro)
if __name__ == '__main__':
cuadrado = Figura("Cuadrado", 5, 5)
print(cuadrado.name, cuadrado.height, cuadrado.width)
print('-',cuadrado.area())
print('-',cuadrado.perimetro())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment