Question
What is the output of the below program?x = 50def func(): global x print('x is', x) x = 2 print('Changed global x to', x)func()print('Value of x is', x)
Answer: Option B
Was this answer helpful ?
The global statement is used to declare that x is a global variable “ hence, when we assign a value to x inside the function, that change is reflected when we use the value of x in the main block.
Was this answer helpful ?
Submit Solution