Progra mme the above ou tput
Use Python
No Goo.gle,No spam
Attachments:
Answers
Answered by
68
#python program to print the pattern
for I in range(1,7):
for j in range(1,I):
print("★",end=" ")
print()
Attachments:
Answered by
14
Answer:
There are different approaches for solving this problem. Assuming that the character is a star.
1. Using nested loops.
for i in range(6):
for j in range(i+1):
print("* ",end="")
print()
2. Using 1 loop.
for i in range(1,7):
print("* "*i)
3. One liner (shortest approach)
print("\n".join(str("* ")*i for i in range(1,7)))
Patterns are generally solved using nested loop although we can make the python c∅de more shorter due to some special features in Python like multiplying any string with numeric value (used in approach two), join() function and so on.
See the attachment.
•••♪
Attachments:
Similar questions