Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Alphabet Pattern 'S' in Python
WhatsApp
Sourabh Somani
9y
39.5
k
0
4
25
Blog
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
Up Next
Alphabet Pattern 'H' in Python
Ebook Download
View all
Coding Principles
Read by 2.5k people
Download Now!
Learn
View all
Membership not found