0% found this document useful (0 votes)
19 views16 pages

Class 4

The document outlines steps to print various patterns in Python using loops. It includes examples of patterns based on user input, such as stars, numbers, and multiplication tables. The document serves as a guide for implementing nested loops to create different visual outputs in programming.

Uploaded by

armaan.dinajpur
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)
19 views16 pages

Class 4

The document outlines steps to print various patterns in Python using loops. It includes examples of patterns based on user input, such as stars, numbers, and multiplication tables. The document serves as a guide for implementing nested loops to create different visual outputs in programming.

Uploaded by

armaan.dinajpur
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
You are on page 1/ 16

PATTERN CONTINUATION

The outer loop tells us


the number of rows,
and the inner loop
tells us the column
Decide the number of rows and columns
needed to print the
pattern.
OR Iterate rows (outer loop)
Accept the number of
rows from a user using
the input() function to
decide the size of a Iterate columns (inner loop or nested loop)
pattern.

Print star or number


STEPS TO
PRINT
Add new line after each iteration of outer loop
PATTERN IN
PYTHON
Rows and Columns

1 1
2 2 2 2
3 3 3 3 3 3
4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5
for i in range(5):
1
for j in range(i+1):
2 2
print(i+1, end=‘’)
3 33
print() 4 444
0
Step 1: 5 5555
i = 0, j = na 1 1
Step 2:
i = 1, j = 0 2 2 2
Step 3:
i = 2, j = 3 3 3 3
Step 4:
i=,j= 4 4 4 4 4
Wap to print the following pattern:

Input: 5
Output:
#
##
###
####
#####
Wap to print the following pattern:

Input: 5
Output:
1
12
123
1234
12345
Wap to print the following pattern:

Input: 5
Output:
1
33
555
7777
99999
1 1 1 1 1

Wap to print the following pattern:

Input: 5 Limit=5
Output: Num=1
for i in range (limit, 0, -1):
11111
for j in range(i):
2222 print(num, end=‘ ’)
333 print()
44 num+=1
5
Wap to print the following pattern:

Input: 5
Output:
55555
4444
333
22
1
Wap to print the following pattern:

Input: 5
Output:
1
12
123
1234
12345
HOMEWORK
Wap to print the following pattern:

Input: 5
Output:
1
21
321
4321
54321
Wap to print the following pattern:

Input: 5
Output:
54321
4321
321
21
1
Wap to print the following pattern:

Input: 5
Output:
12345
22345
33345
44445
55555
Wap to print the following multiplication
table:

Input: 5
Output:
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
8 16 24 32 40 48 56 64
Wap to print the following pattern:

Input: 5
Output:
*
**
***
****
*****
****
***
**
*

You might also like