Last active
November 6, 2016 21:51
-
-
Save tiborsaas/ee778df126a441420678e2229f363c63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Diamond(): | |
def __init__(self, depth): | |
self.depth = depth | |
def draw(self): | |
self.triangle(self.depth//2, 'up') | |
self.triangle(self.depth//2, 'down') | |
def triangle(self, depth, direction): | |
if direction == 'up': | |
buildRange = range(1,depth) | |
else: | |
buildRange = range(depth,0,-1) | |
for line in buildRange: | |
padding = depth - line | |
print( ' ' * padding + '*' * ( line * 2 - 1 ) ) | |
myDiamond = Diamond(11) | |
myDiamond.draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment