Skip to content

Instantly share code, notes, and snippets.

@ksaver
Created August 2, 2019 23:27
Show Gist options
  • Save ksaver/2680bb7714d19985e9da0d15c11d1202 to your computer and use it in GitHub Desktop.
Save ksaver/2680bb7714d19985e9da0d15c11d1202 to your computer and use it in GitHub Desktop.
# Created by me, under the alias "noobcoder" in Sololearn.com
# https://www.sololearn.com/Profile/5439366
# Example of Python code to
# print some simple symmetric shapes
# using "X" and spaces.
def xprint(x, line_width=40):
spaces = (line_width - x) // 2
print(" " * spaces + "X" * x +
" " * spaces)
# Some simple shapes
shapes = {
"square": (0, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 0),
"triangle": (0, 1, 3, 5, 7, 9, 11, 13, 15,
17, 19, 0),
"diamond": (0, 1, 3, 5, 7, 9, 11, 13, 15,
15, 13, 11, 9, 7, 5, 3, 1, 0),
"sandglass": (0, 15, 13, 11, 9, 7, 5, 3,
3, 5, 7, 9, 11, 13, 15, 0),
"cross": (0, 10, 10, 10, 30, 30, 30, 10,
10, 10, 0),
"arrow": (0, 1, 3, 5, 7, 9, 11, 13, 7, 7,
7, 7, 7, 0)
}
for key in shapes.keys():
for x in shapes[key]:
xprint(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment