TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Alphabet Pattern 'S' in Python
Sourabh Somani
Nov 02, 2015
38.4
k
0
4
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
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:
Alphabet Pattern S
Python
Next Recommended Reading
Alphabet Pattern 'H' in Python