0% found this document useful (0 votes)
4 views2 pages

Python Loops Patterns Assignment

The document is a Python Loops Pattern Practice Assignment consisting of 30 pattern questions ranging from easy to tricky, focusing on for loops, nested loops, range(), and pattern building. Each question is followed by a detailed solution, with the first ten solutions provided explicitly. The remaining questions encourage students to attempt independently, covering various complex patterns.

Uploaded by

vineet Tiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Loops Patterns Assignment

The document is a Python Loops Pattern Practice Assignment consisting of 30 pattern questions ranging from easy to tricky, focusing on for loops, nested loops, range(), and pattern building. Each question is followed by a detailed solution, with the first ten solutions provided explicitly. The remaining questions encourage students to attempt independently, covering various complex patterns.

Uploaded by

vineet Tiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Loops Pattern Practice Assignment

30 Pattern Questions (Easy → Tricky) followed by detailed solutions. Focus: for loops, nested
loops, range(), pattern building.

Questions
1. *
2. * ** *** **** *****
3. ***** **** *** ** *
4. 1 12 123 1234 12345
5. 5 54 543 5432 54321
6. 1 22 333 4444 55555
7. 5 44 333 2222 11111
8. 12345 1234 123 12 1
9. 54321 5432 543 54 5
10. 1 21 321 4321 54321
11. Floyd Triangle
12. Right Star Triangle
13. Inverted Right Triangle
14. Number Pyramid
15. Star Pyramid
16. Reverse Star Pyramid
17. Diamond Pattern
18. Hollow Square
19. Hollow Rectangle
20. Hollow Pyramid
21. Binary Triangle
22. Alternating 1-0 Pattern
23. Pascal Triangle
24. Butterfly Pattern
25. X Pattern
26. Hollow Diamond
27. Hourglass Pattern
28. Sandglass Pattern
29. Concentric Number Square
30. Zig-Zag Pattern
Solutions
Q1
for i in range(1,6):
print("*"*i)

Q2
for i in range(1,6):
for j in range(i):
print("*",end="")
print()

Q3
for i in range(5,0,-1):
print("*"*i)

Q4
for i in range(1,6):
for j in range(1,i+1):
print(j,end="")
print()

Q5
for i in range(1,6):
for j in range(5,5-i,-1):
print(j,end="")
print()

Q6
for i in range(1,6):
print(str(i)*i)

Q7
for i in range(5,0,-1):
print(str(i)*(6-i))

Q8
for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end="")
print()

Q9
for i in range(5,0,-1):
for j in range(5,i-1,-1):
print(j,end="")
print()

Q10
for i in range(1,6):
for j in range(i,0,-1):
print(j,end="")
print()

For Questions 11-30, students should first attempt independently. These include pyramids,
diamonds, hollow patterns, Pascal triangle, butterfly, hourglass and concentric square patterns.

You might also like