<- Back to the chapter.

Answer to Problem 3

Question:

Use two for loops, one of them nested, to print the following 10x10 rectangle:

* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *

Answer:

for row in range(10):
    for column in range(10):
        print("*",end=" ")

    # Print a blank line for next row
    print()
Variables:
row=
column=
Output:
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *

Explanation: