Alphabet Pattern 'S' in Python
In this Blog I am printing pattern 'S' using Python.
S-Pattern 1:
Code:
- str="";
- for Row in range(0,7):
- for Col in range(0,7):
- if (((Row == 0 or Row == 3 or Row == 6) and Col > 1 and Col < 5) or (Col == 1 and (Row == 1 or Row == 2 or Row == 6)) or (Col == 5 and (Row == 0 or Row == 4 or Row == 5))):
- str=str+"*"
- else:
- str=str+" "
- str=str+"\n"
- print(str);
Output:
S-Pattern 1:
Code:
- row=15
- col=18
- str=""
- for i in range(1,row+1):
- if((i<=3)or(i>=7 and i<=9)or(i>=13 and i<=15)):
- for j in range(1,col):
- str=str+"*"
- str=str+"\n"
- elif(i>=4 and i<=6):
- for j in range(1,5):
- str=str+"*"
- str=str+"\n"
- else:
- for j in range(1,14):
- str=str+" "
- for j in range(1,5):
- str=str+"*"
- str=str+"\n"
- print(str)
Output: