#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..
Something went wrong.
Something went wrong.
United States Trends
- 1. #DWTS 52.5K posts
- 2. Elaine 39.2K posts
- 3. Robert 105K posts
- 4. Alix 11.5K posts
- 5. Jordan 110K posts
- 6. Dylan 33.7K posts
- 7. Carrie Ann 3,684 posts
- 8. NORMANI 1,854 posts
- 9. Anthony Black 2,537 posts
- 10. Drummond 2,644 posts
- 11. #WWENXT 7,703 posts
- 12. Sixers 4,234 posts
- 13. Suggs 2,471 posts
- 14. Jalen Johnson 3,771 posts
- 15. #DancingWithTheStars 1,433 posts
- 16. Godzilla 32.3K posts
- 17. #iubb 1,152 posts
- 18. Auburn 9,137 posts
- 19. Michigan 85K posts
- 20. Bruce Pearl N/A