← Quiz: Python Functions: all 15 questions
Quiz: Python Functions · Question 12 of 15
What does this print? (code)
What does this print?
count = 0
def add():
global count
count += 1
add()
add()
print(count)
- A.0
- B.1
- C.2
- D.UnboundLocalError
Answer & explanation
Correct answer: 2
global count lets the function change the global variable, and it is called twice.
Can you get the rest right without peeking?
Take the timed Quiz: Python Functions quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →