Python Programming - Functions - Discussion

Discussion Forum : Functions - General Questions (Q.No. 7)
7.
What will be the result of the following code snippet?
x = 10

def multiply_by_two():
    global x
    x *= 2

multiply_by_two()
print(x)
5
20
10
Error
Answer: Option
Explanation:
The global keyword inside the function indicates that the variable x should be treated as a global variable, and its value is multiplied by 2.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.