Python : Nested Loop Test 1

 

Python Nested Loop Test-1

Q1. Write a program to print the following pattern.

S. No

Pattern

Code

1.

1

1 1

1 1 1

1 1 1 1

1 1 1 1 1

 

 

2.

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

 

 

3.

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

 

 

4.

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

 

 

5.

5

5 4

5 4 3

5 4 3 2

5 4 3 2 1

 

 

6.

1

2 3

3 4 5

4 5 6 7

5 6 7 8 9

 

 

7.

1

2 1

3 2 1

4 3 2 1

5 4 3 2 1

 

 

8.

*

* *

* * *

* * * *

* * * * *

 

 

 

 

Solutions :

S. No

Pattern

Code

1.

1

1 1

1 1 1

1 1 1 1

1 1 1 1 1

 

2.

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

 

3.

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

 

4.

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

 

5.

5

5 4

5 4 3

5 4 3 2

5 4 3 2 1

 

6.

1

2 3

3 4 5

4 5 6 7

5 6 7 8 9

 

7.

1

2 1

3 2 1

4 3 2 1

5 4 3 2 1

 

8.

*

* *

* * *

* * * *

* * * * *

 

No comments:

Post a Comment

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet