Embercode
✕
LoopsQuick quiz

Digits and menus in Python

7 questions. Covers Input-driven menus in Python.

Questions 1 to 5 of 7

  1. 1. What does this code print? ``python n = 5040 total = 0 while n > 0: total = total * 10 + n % 10 n //= 10 print(total) ``
  2. 2. What does this code print? The text has three spaces between the words. ``python line = "a call Ana ".strip() parts = line.split(maxsplit=1) print(f"{len(parts)} [{parts[1]}]") ``
  3. 3. Which exception does input() raise when no lines are left to read? Write the class name.

    Type your answer.

  4. 4. Fill in the blank. The built-in function that turns text such as "42" into an integer is ___().

    Type your answer.

  5. 5. A menu is a while True loop with a match inside. One branch is case "q": break. The input is the single line q, and then the input ends. What is printed? ``python while True: line = input() match line: case "q": print("quitting") break case _: print(f"got {line}") print("after loop") ``

5 question(s) left on this page.

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