This repository contains a number of Python interview questions that can be used when vetting potential candidates. It is not advised to use every one of these questions for the same candidate.
-
What is Python?
-
Describe some features of Python.
-
How does Python execute code?
-
What are some built-in types in Python?
-
How do you create a list?
-
How do you create a dictionary?
-
What is PEP8?
-
How can you improve the following code?
import string i = 0 for letter in string.letters: print("The letter at index %i is %s" % (i, letter)) i = i + 1
Bonus points for mentioning
enumerate
and use ofstr.format
. -
What's the fastest way to swap the values bound to two variables?
-
What is the importance of reference counting?
-
Do functions (or methods) return something even if there isn't a
return
statement? If so, what do they return? -
How can you return multiple values from a function/method?
-
What is a list comprehension? Why would you use one?
-
What is a generator? What can it be used for?
-
What is a decorator? How is it represented?
-
How do you reverse a list? Can you come up with at least three ways?
-
How would you merge two sorted lists? They can be any length, or empty.
-
How would you count the lines in a file? How would you do it if the file was too big to hold in memory?
-
What are bindings, i.e., what does it mean for a value to be bound to a variable?
-
What happens if you have an error in an init statement?
-
What is inheritance?
-
What happens in python if you try to divide by zero?
- What is a descriptor?
-
What is the GIL?
-
Do lists and tuples react the same way to hashability?
-
What is a meta class?
- What is a cron job?