Navigation Menu

Skip to content

Commit

Permalink
Pattern of Letter R
Browse files Browse the repository at this point in the history
  • Loading branch information
avinashn committed Jan 18, 2021
1 parent ccba3d4 commit a38d553
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions patterns/Pattern-R.py
@@ -0,0 +1,47 @@
__author__ = 'Avinash'


# Python3 program to print alphabet pattern R

# * * * * * *
# * *
# * *
# * *
# * * * * * * *
# * *
# * *
# * *


def print_pattern(n):
for row in range(n):
for column in range(n):
if (
# first row
(row == 0 and column != 0 and column != n - 1) or

# first column
(column == 0 and row != 0) or

# middle row
(row == n//2 and column != n-1) or

# last column
(column == n-1 and row < n//2 and row != 0) or

# R tail
(row == column and row >= n//2)
):
print("*", end=" ")
else:
print(" ", end=" ")
print()


size = int(input("Enter any size: \t"))

if size < 8:
print("Enter a size minumin of 8")
else:
print_pattern(size)

0 comments on commit a38d553

Please sign in to comment.