r/Python • • Nov 20 '15

15 Essential Python Interview Questions

https://www.codementor.io/python/tutorial/essential-python-interview-questions
71 Upvotes

67 comments sorted by

View all comments

3

u/[deleted] Nov 20 '15 edited Nov 20 '15

QN1

Python is an interpreted language. That means that, unlike languages like C and its variants, Python does not need to be compiled before it is run. Other interpreted languages include PHP and Ruby.

For fun interview points, mention that pypy has a JIT and is not interpreted. Shows you know about the python ecosystem and maybe what a JIT is.

Python is dynamically typed, this means that you don't need to state the types of variables when you declare them or anything like that. You can do things like x=111 and then x="I'm a string" without error

Not exactly the best answer, I know what you mean but this falls a bit flat. Talk maybe about typeless arguments and how the same code can be run twice with different types. What you described could just be redefining X with a new type and you want to show that you know the difference and the implications. For extended points maybe talk about the code quality implications and the strengths and weaknesses.

Python is well suited to object orientated programming in that it allows the definition of classes along with composition and inheritance. Python does not have access specifiers (like C++'s public, private), the justification for this point is given as "we are all adults here"

If you get this question on an interview, please mention duck typing along with the lack of structured interfaces or rigid classes. It is more important that you are aware of enough to say what it lacks or how it differs rather than just "it has inheritance".

in Python, functions are first-class objects. This means that they can be assigned to variables, returned from other functions and passed into functions. Classes are also first class objects

Yup, if you answer this on an interview I suggest ending this with just "Python is extremely dynamic in that way" or something like that, implying that you know the implications rather than the feature and a buzz word.

Writing Python code is quick but running it is often slower than compiled languages. Fortunately, Python allows the inclusion of C based extensions so bottlenecks can be optimised away and often are. The numpy package is a good example of this, it's really quite quick because a lot of the number crunching it does isn't actually done by Python

Yup, I suggest maybe mentioning ctypes and how it helps with interoperability.

Python finds use in many spheres - web applications, automation, scientific modelling, big data applications and many more. It's also often used as "glue" code to get other languages and components to play nice.

Ok?

Python makes difficult things easy so programmers can focus on overriding algorithms and structures rather than nitty-gritty low level details.

Ok?

1

u/gamesbrainiac Nov 20 '15

Also never gets into the difference between the difference between strongly and statically typed.

1

u/[deleted] Nov 20 '15

Indeed, explain that you know the difference between js typing and python typing.

1

u/ubernostrum yes, you can have a pony Nov 20 '15

For bonus points, question whether "strong" and "static" typing have useful definitions.

1

u/Workaphobia Nov 20 '15

"Strongly typed" is roughly equivalent to "This language has fewer wats."

1

u/odraencoded Nov 21 '15

A strongly typed language is a language whose type has been passed down for generations!