❔ Interview question
What is the output of the following code?
Answer:
[1, 2, 3, 4]
tags: #python #interview #coding #programming #datastructures #list #mutable #dev
By: t.iss.one/DataScienceQ 🚀
What is the output of the following code?
x = [1, 2, 3]
y = x
y.append(4)
print(x)
Answer:
tags: #python #interview #coding #programming #datastructures #list #mutable #dev
By: t.iss.one/DataScienceQ 🚀
❔ Interview question
**What will be the output of this code?**
```python
x = [1, 2, 3]
y = x[:]
y[0] = 10
print(x)
```
Answer:
<spoiler>||[1, 2, 3]||</spoiler>
tags: #python #interview #coding #programming #list #slicing #mutable #dev
By: t.iss.one/DataScienceQ 🚀
**What will be the output of this code?**
```python
x = [1, 2, 3]
y = x[:]
y[0] = 10
print(x)
```
Answer:
<spoiler>||[1, 2, 3]||</spoiler>
tags: #python #interview #coding #programming #list #slicing #mutable #dev
By: t.iss.one/DataScienceQ 🚀
Telegram
Python Data Science Jobs & Interviews
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
Admin: @Hussein_Sheikho
⁉️ Interview question
What is the output of the following code?
Answer:
3
#⃣ tags: #python #advanced #coding #programming #interview #deepcopy #mutable #dev
By: t.iss.one/DataScienceQ 🚀
What is the output of the following code?
import copy
a = [1, 2, [3, 4]]
b = copy.deepcopy(a)
b[2][0] = 'X'
print(a[2][0])
Answer:
#⃣ tags: #python #advanced #coding #programming #interview #deepcopy #mutable #dev
By: t.iss.one/DataScienceQ 🚀
Telegram
Python Data Science Jobs & Interviews
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
Admin: @Hussein_Sheikho
⁉️ Interview question
What is the output of the following code?
Answer:
[1, 2]
#⃣ tags: #python #advanced #coding #programming #interview #defaultarguments #mutable #dev
By: t.iss.one/DataScienceQ 🚀
What is the output of the following code?
def func(a, b=[]):
b.append(a)
return b
print(func(1))
print(func(2))
Answer:
#⃣ tags: #python #advanced #coding #programming #interview #defaultarguments #mutable #dev
By: t.iss.one/DataScienceQ 🚀