How to print alphabet B in Python
To print pattern B here's the code given below
# code
for i in range(5):
for j in range (6):
if i in {0,2,4} and j in {0,1,2,3} or j==0 or i in {1,3} and j==4:
print("*",end= ' ')
else:
print(" ",end= ' ')
print()
first of all we have to defin the range of Rows & columns.Here in the below code i is for rows and j is for columns.Range (1,6) means it will print 1 to 5 & (1,7) means to 6 it will print.
for i in range(5):
for j in range (6):
now
To draw this we need this code....
****
*
****
*
****
if i in {0,2,4} and j in {0,1,2,3} or j==0 or i in {1,3} and j==4:
print("*",end= ' ')
now i've to print star in column c5.
by using below code we can do this
if i in {0,2,4} and j in {0,1,2,3} or j==0 or i in {1,3} and j==4:
print("*",end= ' ')
After all this we have to print the space between the stars
to print space such that it will appear as a right alphabet
else:
print(" ",end='')
now to change row we required:
print()
now to change row we required:
print()
please share & commentme down if you have any problems that youare facing i printing patterns.
Post a Comment