← Quiz: Python Introduction: all 15 questions
Quiz: Python Introduction · Question 12 of 15
A program has four correct print lines and then print(total) on line 5, where total was never created. What do you see…
A program has four correct print lines and then print(total) on line 5, where total was never created. What do you see when you run it?
- A.Only the error, because Python checks every line before running
- B.The output of lines 1 to 4, then a NameError for line 5
- C.The output of all five lines
- D.Nothing at all
Answer & explanation
Correct answer: The output of lines 1 to 4, then a NameError for line 5
Python runs line by line, so the first four lines run before it reaches the bad line and stops.
Can you get the rest right without peeking?
Take the timed Quiz: Python Introduction quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →