4.2.4
Nested loops (4.2.4) is a Class 10 Computer Science lesson for the Punjab boards. It walks through the idea in plain steps, then sets a short check, in English, Urdu or Roman Urdu.
Your guide: Miss HiraExplains computers with chai, cricket and your phone.
Chapter 1 of every subject is free. Unlock every chapter of this class with the full course.
Unlock full courseAlready paid? Sign in with the Google account you paid with.
A nested loop is a loop inside another loop. For every pass of the outer loop, the inner loop runs completely.
for i in range(3): for j in range(4) prints 12 pairs, from i=0, j=0 to i=2, j=3. The total number of inner passes is outer × inner = 3 × 4.
Patterns use the outer loop for rows and the inner loop for columns: print("*", end=" ") inside, and an empty print() after each row to start a new line.
Step 1 / 1
A nested loop is a loop inside another loop. For every pass of the outer loop, the inner loop runs completely.
for i in range(3): for j in range(4) prints 12 pairs, from i=0, j=0 to i=2, j=3. The total number of inner passes is outer × inner = 3 × 4.
Patterns use the outer loop for rows and the inner loop for columns: print("*", end=" ") inside, and an empty print() after each row to start a new line.
Total inner runs = outer passes × inner passes.
Found a mistake? Tell us the lesson and the line at exciting@boringeducation.com.
No ads. Tell us what to fix.