Embercode
✕
Pattern PrintingQuick quiz

Rows and mirrors

7 questions. Covers Mirror symmetry in Python.

Questions 1 to 5 of 7

  1. 1. What is the second line printed? ``python for row in range(1, 4): cells = [] for col in range(1, 4): cells.append(str(row * col + 1)) print(",".join(cells)) ``
  2. 2. What is the third line printed? ``python n = 4 for i in range(n): for _ in range(n - 1 - i): print(" ", end="") for j in range(1, i + 2): print(j, end="") for j in range(i, 0, -1): print(j, end="") print() ``
  3. 3. This should print # on three lines, but it prints #, ## and ###. ``python line = [] for row in range(1, 4): line.append("#") print("".join(line)) `` What is the fix?
  4. 4. This code should print a top row of 5 characters for n = 5, but the top row has 6. ``python n = 5 for i in range(n): for _ in range(n - i): print(" ", end="") for j in range(1, i + 2): print(j, end="") for j in range(i, 0, -1): print(j, end="") print() `` Which change fixes it?
  5. 5. A learner writes row = "* *" and then calls row.replace(" ", "."), expecting row to hold *..*. Is that expectation right?

5 question(s) left on this page.