Embercode
✕
Learning with AIQuick quiz

Reading code

6 questions. Covers Reading other people's code.

Questions 1 to 5 of 6

  1. 1. You open a program you did not write. Put these steps in the order the lesson gives them.

    Use the arrows to put the steps in order.

    1. 1.Trace one input from start to finish, by hand or with print lines in a copy
    2. 2.Draw the call diagram as an indented tree of which function calls which
    3. 3.Make a table of each file's job and the files it imports
    4. 4.Open the entry point, such as main.py, and read its import lines
  2. 2. A program stops with a traceback. Put these steps in the order the lesson says to read it.

    Use the arrows to put the steps in order.

    1. 1.Look at the line just above the last one, which is the code that failed
    2. 2.Go up the traceback one caller at a time, to see who made each call
    3. 3.Reach the top, where the program started, and find where the bad value came from
    4. 4.Read the last line, which names the kind of error and the bad value, such as KeyError: 'bagel'
  3. 3. A result looks wrong, but the program shows no error. Put these steps in the order the lesson gives them.

    Use the arrows to put the steps in order.

    1. 1.Decide whether the rule in that step is the one the shop wants
    2. 2.Trace the value through each step of the calculation
    3. 3.Find the step where the number changes
  4. 4. What does this code print? ``python TAX_RATE = 0.08 def add_tax(amount): return round(amount * (1 + TAX_RATE), 2) print(add_tax(8.00)) ``
  5. 5. What does this code print? ``python print(round(4.25 * 3 * 0.9, 2)) ``

2 question(s) left on this page.