🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python Functions: all 15 questions

Quiz: Python Functions · Question 4 of 15

What does this print? (code)

What does this print?

x = 5
def change():
    x = 10
change()
print(x)
  1. A.5
  2. B.10
  3. C.None
  4. D.Error
Answer & explanation

Correct answer: 5

The x inside the function is a new local variable; the global x is unchanged.

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 →