Skip to content

Instantly share code, notes, and snippets.

@gibbonweb
Created September 9, 2011 09:00
Show Gist options
  • Save gibbonweb/1205801 to your computer and use it in GitHub Desktop.
Save gibbonweb/1205801 to your computer and use it in GitHub Desktop.
#! /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