Python Data Science Jobs & Interviews
18K subscribers
142 photos
4 videos
14 files
255 links
Your go-to hub for Python and Data Science—featuring questions, answers, quizzes, and interview tips to sharpen your skills and boost your career in the data-driven world.

Admin: @Hussein_Sheikho
Download Telegram
Question 20 (Beginner):
What is the output of this Python code?

x = [1, 2, 3]
y = x
y.append(4)
print(x)



A) [1, 2, 3]
B) [1, 2, 3, 4]
C) [4, 3, 2, 1]
D) Raises an error

#Python #Lists #Variables #Beginner

By: https://t.me/DataScienceQ

**Correct answer: B) `[1, 2, 3, 4]`**

*Explanation:
- `y = x` creates a reference to the same list object
- Modifying `y` affects `x` because they point to the same memory location
- To create an independent copy, use
y = x.copy() or y = list(x)*