Computer Science, asked by sufisayed329, 11 months ago

Different star patterns codes

Answers

Answered by fiercespartan
5

NOTE: I will be taking the number as 3 for all the star patterns. I know a few star patterns and I am going to drop the code below. If you have any further star patterns in mind, please post an other question and I will answer it as soon as possible :)

___________________________________________

1st pattern:

\boxed{\\\begin{minipage}{24}\\*\\**\\***\\****\\\end{minipage}}

CODE:

for i in range(1,4):

   print( ' * ' * i  )

___________________________________________

2nd pattern:

\boxed{\\\begin{minipage}{24}\\****\\***\\**\\*\\\end{minipage}}

CODE:

for i in reversed(range(1,4)):

   print( ' * ' * i  )

___________________________________________

3rd pattern:

#Unable to use latex to get this pattern

\boxed{\begin{array}{c@{}c@{}c@}&&*\\&*&*\\ *&*&*\end{array}}

CODE:

for x,y in zip(range(1,4),reversed(range(3))):

print(' '*y + '*'*x)

___________________________________________

These are the most common star patterns

Similar questions