Python Programming - Variables - Discussion
Discussion Forum : Variables - General Questions (Q.No. 15)
15.
What is the value of x after executing the following code:
x = 10
x += 5
x *= 2
print(x)
Answer: Option
Explanation:
In Python, the +=
operator is used to add a value to a variable, and the *=
operator is used to multiply a variable by a value.
In this case, x
starts at 10, then 5 is added to it to make it 15, and then it is multiplied by 2 to make it 30.
The final value of x
is 30.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers