This post was written by Cameron Wilson, and was originally published at Educative.io
This post will cover interview questions on the Python prog...
For further actions, you may consider blocking this person and/or reporting abuse
Can you expand a bit on question 2? If I were to convert a list into a tuple, I would probably throw the list right at the tuple constructor:
The answer provided seems to be answering a different question.
I agree with that. I run the code, and this is the result.
But the real answer should be something like this:
This is a really informative article. On question 13, is it possible to add a note that the behavior of
rangeandxrangethat is explained is based on Python 2. In Python 3,xrangeis deprecated and the default behavior it had is moved torange.There are so many things in here which are flat-out incorrect or warped beyond recognition it's really quite concerning.
People have already pointe dout Question 2 and Question 13, but there's plenty of other examples.
Question 11 manages to omit the key property of inheritance (that of substitution allowing specialisation). Question 12 makes me cry, especially following on from Question 11, which is literally about one form of polymorphism that it somehow fails to mention.
It's a particular shame because Python is rich in polymorphic techniques, from Row Polymorphism (aka Duck Typing) to Inclusion Polymorphism (aka subtyping and inheritance) to Polytypism (where we don't care about the type at all for much of the code).
If an interviewer accepts some of these answers as correct for anything but an entry-level Junior position, I'd worry about accepting the job.
Not quite. The list itself is mutable, but objects referenced in that list can be either mutable or immutable, and each element of said list is considered a reference (and possibly garbage collected thereafter).
Thanks! That's the best I've seen yet.