Embercode
✕
Pattern PrintingQuick quiz

Shapes

6 questions. Covers Hourglass, arrow and cross shapes in Python.

Questions 1 to 5 of 6

  1. 1. What is printed on the second line? ``python def row(width, widest): indent = (widest - width) // 2 return " " * indent + "*" * width def main(): widest = 3 stem_height = 2 for w in range(1, widest + 1, 2): print(row(w, widest)) for _ in range(stem_height): print(row(1, widest)) main() ``
  2. 2. What is printed on the third line? ``python def row(width, widest): indent = (widest - width) // 2 return " " * indent + "*" * width def main(): size = 4 middle = size // 2 for r in range(size): width = size if r == middle else 1 print(row(width, size)) main() ``
  3. 3. In the hourglass program from the lesson, why does the second loop start at w = 3 and not at w = 1?
  4. 4. In an hourglass with widest = 7, a row has width 3. How many spaces come before its stars?
  5. 5. Which operator repeats a string, so that " " * 2 gives two spaces? Give the symbol only.

    Type your answer.

5 question(s) left on this page.

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