Created
April 3, 2014 07:29
-
-
Save samjarman/9949826 to your computer and use it in GitHub Desktop.
Stars - COSC 121 Challenge
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
def square_of_stars(n): | |
line = " * " * n | |
for i in range(n): | |
print (line) | |
def triangle(n): | |
for i in range(1, n+1): | |
print(" * " * i) | |
def empty_square(n): | |
print(" * " * n) | |
for i in range(n-2): | |
print(" * " + (" " * (n-2)) + " * ") | |
print(" * " * n) | |
def triangle2(n): | |
for i in range(1, n+1): | |
print(" " * (n - i) + " * " * i) | |
def diamond(n): | |
''' This goes in increments of 2 up to n, and then back down again to form a diamond shape''' | |
for i in range (1, (n/2) + 1): | |
print (" " * ((n/2) -i ) + " * * " * i + " " * ((n/2) - i)) | |
for i in range ((n/2)): | |
print (" " * ((n/2) - ((n/2) - i) ) + " * * " * ((n/2) - i) + " " * ((n/2) - ((n/2) - i))) | |
def print_all(n): | |
square_of_stars(n) | |
triangle(n) | |
empty_square(n) | |
triangle2(n) | |
diamond(n) | |
print_all(int(raw_input("Enter the number of columns: "))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment