Embercode
✕
Pattern PrintingQuick quiz

Zigzag and tables in Python

7 questions. Covers Aligned tables with f-strings.

Questions 1 to 5 of 7

  1. 1. With three rows, what does this call print? ``python def row_of(index, num_rows): cycle = 2 * (num_rows - 1) position = index % cycle if position < num_rows: return position return cycle - position print(row_of(5, 3)) ``
  2. 2. What does this print? ``python print(f"[{12:4d}][{12:<4d}]") ``
  3. 3. In the bouncing-star program (the first zigzag example), when the marker is on the top row, what value does direction get set to?

    Type your answer.

  4. 4. In the f-string f"{price:10.2f}", how many digits come after the decimal point?

    Type your answer.

  5. 5. In the look-ahead version of the bounce (Example 2), which test turns the direction around?

5 question(s) left on this page.

Typed answers ignore extra spaces and, for most questions, capital letters.