I am starting a series of posts about my own base of interviewing questions. Of course, it is not full and it doesn't have any answers and maybe some of the questions seem weird or even stupid, but I think they are good for finding the right candidate for Python position.
- Python interview questions. Part I. Junior
- Python interview questions. Part II. Middle
- Python interview questions. Part III. Senior
We all know that senior is not just a technical role that bound with years of experience and knowledge about his tools, they also have mentoring skills, some management skills in order to measure tasks and their time, and they tend to have some architecture skills, etc. My questions here are only for the technical side of Python senior developers.
Q: Is it possible to use the construction True = False?
Q: When will the
else part of
try...except...else be executed?
Q: What is monkey patching? How to use it in Python? Example? Is it ever a good idea?
Q: How are
set implemented internally?
Q: What is MRO in Python? How does it work?
Q: Does Python has an assignment operator?
Q: What are descriptors? Is there a difference between a descriptor and a decorator?
Q: How are arguments passed by value or by reference in Python?
Q: What tools help you find code smells in code or perform static code analysis? What else do you know/use to make your code maintainable and readable?
Q: Whenever Python exits, why isn't all the memory de-allocated?
Q: Is it possible to have a producer thread reading from the network and a consumer thread writing to a file, really work in parallel? What about GIL?
Q: What is GIL? Why GIL is still exist?
Q: What is the process of compilation and linking in Python?
Q: How to package code in Python? What package managers do you know?
Q: How to work with transitive dependencies?
Q: What are the wheels and eggs? What is the difference?
Q: How to distribute Python code?
Q: How to package binary dependencies in Python?
Q: What is a package manager? Which one do you use? Why?
Q: What is Cython?
Q: How to speed up existing Python code?
Q: How to isolate Python code? What are virtualenvs? What is docker?
Q: Is Python a functional language? Specify the requirements for code written in a functional paradigm.
Q: Identify the pitfalls/limitations of the functional code.
Q: Explain how can you access a module written in Python from C? Vise versa?
Q: What are .pth files?
Q: What advantages do NumPy arrays offer over (nested) Python lists?
Q: What is cuda?
Q: What is Anaconda platform? Why do we need it?
Q: What does the
PYTHONOPTIMIZE flag do?
Code involving questions
Q: Give an example of a filter and reduce over an iterable object.
Q: You have a function that takes other functions as an argument. How to validate the value of an argument?
Q: Explain how to reverse a generator?
Q: You need to implement a function that should use a static variable (for example, a call counter). You cannot write any code outside the function and you do not have information about external variables (outside your function). How to do it?
Q: You have a function that takes an argument that must be in given frameworks [a, b]. Arrange the test implementation options to increase the speed at which the test is performed.
- argument in list [a, b]
- a <= argument <= b
- a in range (a, b + 1)
Q: What methods and in what order are called when
print (A() + B()) is executed?
Q: How to implement a dictionary from scratch using core Python?
Q: What's the output?
def Foo(): yield 42; return 666
Q: What will be the output of the following code?
>>> a = []*3 >>> a.append(1) >>> print(a) # [, , 
Q: Place the following functions below in order of their efficiency. How would you test your answer?
def f1(lIn): l1 = sorted(lIn) l2 = [i for i in l1 if i<0.5] return [i*i for i in l2]
def f2(lIn): l1 = [i for i in lIn if i<0.5] l2 = sorted(l1) return [i*i for i in l2]
def f3(lIn): l1 = [i*i for i in lIn] l2 = sorted(l1) return [i for i in l1 if i<(0.5*0.5)]
Q: Write a one-liner that will count the number of capital letters in a file. Your code should work even if the file is too big to fit in memory.
Q: Output? Why? Is this inheritance?
class C: pass type (C ()) type (C)
Q: What's the output we get from running the following?
big_num_1 = 1000 big_num_2 = 1000 small_num_1 = 1 small_num_2 = 1 big_num_1 is big_num_2 small_num_1 is small_num_2
Q: How is this possible?
_MangledGlobal__mangled = 23 class MangledGlobal: def test(self): return __mangled >>> MangledGlobal().test() 23
Q: What's the output?
Q: You saw the following piece of code. What is wrong with this code? Why is it needed?
if __debug__: assert False, ("error")
Buy me a coffee