Created
September 19, 2021 04:07
-
-
Save shinysu/288c58a5b48adc446da356e6a57b6b5f to your computer and use it in GitHub Desktop.
Patterns
This file contains hidden or 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 star_row(n): | |
for i in range(n): | |
print('*', end=' ') | |
rows = int(input("Enter the number of rows: ")) | |
for i in range(1, rows+1): | |
star_row(i) | |
print() |
This file contains hidden or 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
''' | |
1 | |
1 2 | |
1 2 3 | |
1 2 3 4 | |
1 2 3 4 5 | |
''' | |
def number_row(n): | |
for i in range(n): | |
print(i+1, end=' ') | |
rows = int(input("Enter the number of rows: ")) | |
for i in range(1, rows+1): | |
number_row(i) | |
print() |
This file contains hidden or 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 spaces(n): | |
for i in range(n): | |
print(end=' ') | |
def star_row(n): | |
for i in range(n): | |
print('*', end=' ') | |
rows = int(input("Enter the number of rows:")) | |
blanks = rows | |
for i in range(rows+1): | |
spaces(blanks) | |
star_row(i) | |
blanks -= 1 | |
print() |
This file contains hidden or 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
''' | |
1 | |
1 2 | |
1 2 3 | |
1 2 3 4 | |
1 2 3 4 5 | |
''' | |
def spaces(n): | |
for i in range(n): | |
print(end=' ') | |
def star_row(n): | |
for i in range(n): | |
print(i+1, end=' ') | |
rows = int(input("Enter the number of rows:")) | |
blanks = rows | |
for i in range(rows+1): | |
spaces(blanks) | |
star_row(i) | |
blanks -= 1 | |
print() |
This file contains hidden or 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 plus_line(): | |
print("+ ", end='') | |
for i in range(4): | |
print('- ', end='') | |
print("+ ",end='') | |
for i in range(4): | |
print('- ', end='') | |
print("+") | |
def other_line(): | |
print("| ", end='') | |
for i in range(4): | |
print(" ", end='') | |
print("| ", end='') | |
for i in range(4): | |
print(" ", end='') | |
print("|") | |
for x in range(1, 12): | |
if x == 1 or x == 6 or x == 11: | |
plus_line() | |
else: | |
other_line() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment