#pythongotcha search results

Ah, the classic mutability trap! Both lists point to the same object—like two names for one dog. Change one, the other barks differently. Output: [9, 2, 3, 4]. Shared fate! 🐶🔧 #PythonGotcha


Wah, jebakan klasik Python nih—instance variable nyelonong ganti class var! Aku dulu pasti jawab 10 10 10 sambil pede, eh ternyata 10 5 5. Siapa lagi yang pernah kena prank gini pas interview? 😆 #PythonGotcha #CodingQuiz

What will be the output of the following Python code? class Test: x = 5 t1 = Test() t2 = Test() t1.x = 10 print(t1.x, t2.x, Test.x)



#pythongotcha : als je een int deelt door een int, krijg je een int: 14/5=2, terwijl met floats 14.0/5.0=2.799..


Q4 Ans: [1,2,3,4,5,6] The default arg, “my_list”, is mutable, so it isn't instantiated with every function call Calling the fn twice adds the other args to the same list instance each time Don't use mutable types as default args! #ManGroupPyQuiz #pythongotcha


Q8 Ans: 12 1 123 1 The += operator only uses the __iadd__ method if it exists. Strings are immutable so do not have __iadd__ therefore lines 3 and 7 are equivalent #ManGroupPyQuiz #pythonquiz #pythongotcha


Wah, jebakan klasik Python nih—instance variable nyelonong ganti class var! Aku dulu pasti jawab 10 10 10 sambil pede, eh ternyata 10 5 5. Siapa lagi yang pernah kena prank gini pas interview? 😆 #PythonGotcha #CodingQuiz

What will be the output of the following Python code? class Test: x = 5 t1 = Test() t2 = Test() t1.x = 10 print(t1.x, t2.x, Test.x)



Ah, the classic mutability trap! Both lists point to the same object—like two names for one dog. Change one, the other barks differently. Output: [9, 2, 3, 4]. Shared fate! 🐶🔧 #PythonGotcha


Q8 Ans: 12 1 123 1 The += operator only uses the __iadd__ method if it exists. Strings are immutable so do not have __iadd__ therefore lines 3 and 7 are equivalent #ManGroupPyQuiz #pythonquiz #pythongotcha


Q4 Ans: [1,2,3,4,5,6] The default arg, “my_list”, is mutable, so it isn't instantiated with every function call Calling the fn twice adds the other args to the same list instance each time Don't use mutable types as default args! #ManGroupPyQuiz #pythongotcha


#pythongotcha : als je een int deelt door een int, krijg je een int: 14/5=2, terwijl met floats 14.0/5.0=2.799..


No results for "#pythongotcha"
No results for "#pythongotcha"
Loading...

Something went wrong.


Something went wrong.


United States Trends