Created
September 9, 2011 09:00
-
-
Save gibbonweb/1205801 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
#! /usr/bin/env python | |
# coding: utf-8 | |
import math | |
class Rhombus (object): | |
""" | |
A freakin rhombus | |
""" | |
def __init__(self, n): | |
self.n = n | |
def draw(self): | |
for y in range(-self.n-1,self.n+2): | |
line = "" | |
for x in range(-self.n-1,self.n+2): | |
if abs(x)+abs(y) > self.n: | |
line = line + " * " | |
else: | |
line = line + " " | |
print line | |
def test(): | |
""" | |
Test program. | |
""" | |
for i in range(10): | |
r = Rhombus(i) | |
r.draw() | |
if __name__ == "__main__": test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment