Python is a general purpose, high-level and interpreted
programming language. The
syntax of Python is as simple as You write the English Language. It is very easy to
print any pattern, alphabets (A-Z) or numeric’s while using Python
Programming Language .The only concept behind any pattern
is known as Looping. With the use of looping we can iterate the condition and
print the specific pattern.
Python often use FOR loop to
print any pattern or alphabets.There are two loops used to print pattern ,first
is the outer loop used to handle the row and the second , inner loop used for
handling the column.
◻️Print an alphabet A with asterisk.
Alpha_A.py
for row in range(7):
for col in range(5):
if(row!=0 and (col==0 or col==4) ) or ((row==0 or row==3) and(col>0 or
col<4)):
print("*",end="")
else:
print(end=" ")
print()
Output:
Output:
◻️Print an alphabet B with asterisk.
Alpha_B.py
for row in range(7):
for col in range(5):
if
col==0 or (col==4 and (row%3!=0)) or ((row%3==0)and (col>0 and col<4)):
print("*",end="")
else:
print(end=" ")
print()
Output:
Output:
◻️Print an alphabet C with asterisk.
Alpha_C.py
for row in range(6):
for col in range(5):
if(row!=0
and row!= 5 and(col==0 )) or ((row==0 or row==5) and (col>0 and col<4)):
print("*",end="")
else:
print(end="
")
print()
Output:
◻️Print an alphabet D with asterisk.
Alpha_D.py
for row in range(6):
for col in range(5):
if(row!=0
and row!= 5 and(col==0 or col==4 )) or ((row==0 or row==5) and (col<4)):
print("*",end="")
else:
print(end="
")
print()
Output:
◻️Print an alphabet E with
asterisk.
Alpha_E.py
for row in range(7):
for col in range(6):
if(col==0 ) or ((row==0 or row==3 or row==6) ):
print("*",end="")
else:
print(end=" ")
print()
Output:
◻️Print an alphabet M with asterisk.
Using for loop you can print alphabet M.
Alpha_M.py
for row in range(7):
for col in range(7):
if
col==0 or col==6 or ((row==col) and (col>0 and col<4)) or (row==1 and
col==5) or (row==2 and col==4):
print("*",end="")
else:
print(end=" ")
print()
Output:
◻️Print an alphabet N with asterisk.
With the use of looping we can iterate the condition and print the specific pattern. Here we used the for loop to print alpha character N.
Alpha_N.py
for row in range(6):
for col in range(6):
if(
(col==0 or col==5) ) or ((row-col==0) ):
print("*",end="")
else:
print(end=" ")
◻️Print an alphabet O with asterisk
Alpha_O.py
for row in range(6):
for col in range(5):
if(row!=0 and
row!= 5 and (col==0 or col==4 )) or ((row==0 or row==5) and (col>0 and
col<4)):
print("*",end="")
else:
print(end="
")
print()
Output:
◻️Print an alphabet P with asterisk
It is very easy to print any pattern,alphabets or numeric’s while using Python Programming Language . The only concept behind any pattern is known as Looping. With the use of looping we can iterate the condition and print the specific pattern. Here we used the for loop to print character P.
Alpha_P.py
for row in range(7):
for col in range(5):
if col==0 or
(col==4 and (row==1 or row==2)) or((row==0 or row==3)and ( col>0 and
col<4)):
print("*",end="")
else:
print(end=" ")
print()
Output:
Output:
Using Python, it is very easy to print alphabets, numeric’s or any other pattern. The only concept behind any shape is called Looping. By using for loop you can print alphabet R.
Alpha_R.py
for row in range(7):
for col in range(5):
if
col==0 or (col==4 and (row==1 or row==2)) or((row==0 or row==3) or
(row-col==3)and ( col>0 and col<4)):
print("*",end="")
else:
print(end="
")
print()
Output:
◻️Print an alphabet Z with asterisk.
Alpha_Z.py
for row in range(6):
for col in range(6):
if( (row==0
or row==5) ) or ((row+col==5) ):
print("*",end="")
else:
print(end="
")
print()
Output:
0 Comments