I'm starting a series of posts about my own database of interview questions. Of course, it's not complete and there are no answers, and some questions may seem strange or even silly, but I think they're good for finding the right Python candidate for the job.


Questions

Q: What is Python?

Q: What is the lambda function in Python? Why does it exist in Python?

Q: What is pass in Python?

Q: What is *args, **kwargs in function definition?

Q: What is docstring in Python? How to write them? Are they required?

Q: What are the built-in data types that Python provides? Which of them are mutable, which are immutable?

Q: What is the difference between list and tuple types in Python?

Q: What keywords can be used in conjunction with the for keyword?

Q: What could be the key in dict?

Q: What's the difference between globals(), locals(), and vars()?

Q: What is PEP8?

Q: What is slicing in Python?

Q: Is it possible to have a negative index in iterative types in Python?

Q: What is the __init__.py module? What it's for?

Q: How can I swap values of variables in Python?

Q: How do I view object methods?

Q: How do you get documentation on objects' methods in Python?

Q: What is a module in python? What is a package? What is the difference between packages and modules in Python?

Q: Can you write multithreading applications in Python? What is the difference between multithreading and multiprocessing?

Q: What is a decorator? How to create a custom decorator?

Q: What is @classmethod, @staticmethod, @property?

Q: What is the difference between @classmethod and @staticmethod?

Q: Does Python fully support OOP?

Q: What is the __dict__ attribute of an object in Python?

Q: What the `self' keyword is used for in Python?

Q: What is the __init__ function used for?

Q: Explain how to make a Python script executable on Unix?

Q: What is pickling and unpickling(marshaling and unmarshaling)?

Code involving questions

Q: Write a function that produces the Fibonacci sequence.

Q: How to translate a string containing a binary code (1 and 0) into a number (integer)? Write a function to do this.

Q: How to check that tuple A contains all elements of tuple B. Do both tuples contain unique values? Write a function to do this.

Q: What is the output of the following code?

def f():
     x = 15
     print(x)
x = 12
f()

Q: How to convert a string to a number that consists of letters ASCII code. Example: 'abcd' -> 979899100. Write a function to do this.

Q: How to remove empty lines from a list of lines (with a length of 0). Write a function to do this.

Q: Write a function that counts all distinct pairs with a difference equal to k.

Q: Write a function that returns a string of numbers from 0 to 100, "0123456789101112...".

Q: Write a function that makes a list with unique items from a list with duplicate items. Example: [1, 1, 2, 3, 3] -> [1, 2, 3].

Q: Make a list of prime numbers from the range (1, 100) using Python.

Q: Write a program that prints the numbers from 1 to 20. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers that are multiples of both three and five print “FizzBuzz”.

Recommended books

Last updated Sat Apr 10 2021