Python Nested for Loops Practice Exercises
Before going through this blog better go through the basic for loops
Nested For Loops — Loops can be iterate in python
A nested loop with in a loop that occur within another loop.
syntax:
f or (first iterable variable) in (outer loop):
[statements]for (second iterable variable) in (nested loop):
[statements]
Exercise 1: Write question words 3 times using nested loops
Nested for loops can be useful for iterating through items with in list composed of lists.In list composed of lists ,if we employ just one for loop ,the program will output each internal list as and item
Exercise 2 : Use single for loop to access each list
Exercise 3 : Using Nested for loop access each individual element from list with in the list
Exercise 4 : Multiply with place values[10’s,100’s] to the given lists
Exercise 5: print the fallowing output
1
2 2
3 3 3
4 4 4 4
Exercise 6: Skip ovals to print from the sentence ‘Python Logic For Kids’
Exercise 7 : Print the * pattern using nested for loops
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
Exercise 8 : Print given pattern
*
**
***
****print single star at first row 2 stars in the second row and continue
doing this in a similar fashion
Exercise 9 :Print odd number patterns
*
***
*****
*******
Exercise 10 : Print Alphabets
A
B C
D E F
G H I J
K L M N O
Exercise 11 : Print A one time B two times …
A
B B
C C C
D D D D
E E E E E
# Exercise 12 : Print your name in 3 rows and columns
Will meet with many exercises with ‘break’ and ‘continue’ with loops in python.