Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 15)
15.
What is the output of the following Python code?
x = [1, 2, 3]
y = x + [4, 5]
z = x.extend([4, 5])
print(x, y, z)
Answer: Option
Explanation:
x
is a list with values [1, 2, 3]
.
y
is the result of concatenating x
with [4, 5]
.
z
is the result of extending x
with [4, 5]
, but it returns None
.
The values of x
, y
, and z
are printed.
Thus, the output is [1, 2, 3, 4, 5] [1, 2, 3, 4, 5] None
.
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