Complete the code to print numbers from 1 to 3 using a while loop.
i = 1 while i [1] 3: print(i) i += 1
The condition i <= 3 makes the loop run while i is less than or equal to 3, printing 1, 2 and 3.
Complete the code to print a 3x3 grid of stars using nested while loops.
row = 0 while row < 3: col = 0 while col [1] 3: print('*', end='') col += 1 print() row += 1
The inner loop runs while col < 3 to print 3 stars per row.
Fix the error in the nested while loops to print numbers 1 to 3 in each row for 3 rows.
row = 1 while row <= 3: col = 1 while col [1] 3: print(col, end=' ') col += 1 print() row += 1
The inner loop should run while col <= 3 to include 3 in the output.
Fill both blanks to create a nested while loop that prints a triangle of stars with 4 rows.
row = 1 while row [1] 4: col = 1 while col [2] row: print('*', end='') col += 1 print() row += 1
The outer loop runs while row <= 4 to print 4 rows.
The inner loop runs while col <= row to print stars increasing each row.
Fill all three blanks to create nested while loops that print a 3x3 grid of numbers counting from 1 to 9.
num = 1 row = 1 while row [1] 3: col = 1 while col [2] 3: print(num, end=' ') num [3] 1 col += 1 print() row += 1
The outer loop runs while row <= 3 to print 3 rows.
The inner loop runs while col <= 3 to print 3 columns.num += 1 increases the number each time.