You are on page 1of 6

Python

Exceptions
1. What is an exception in Python?
2. Can you explain the difference between errors and exceptions in Python?
3. How do you handle exceptions in Python?
4. How can you ensure that a certain code block runs no matter whether there’s an
exception or not?
5. Can you give me some examples of built-in exceptions in Python?
6. When should you use assertions instead of try/except blocks?
7. What are the best practices to follow when using try/except blocks?
8. How does the raise keyword work in Python?
9. How does the assert statement work in Python?
10. What’s the difference between raising an error and throwing an exception in Python?
11. Is it possible for a finally clause to be executed even if an exception has occurred in the
preceding try clause? If yes, then how?
12. What do you understand about custom exceptions in Python?
13. What is your opinion on Python documentation standards? Are they sufficient?
14. Why is the else clause used in try/except blocks?
15. What do you understand about the traceback module in Python?
16. How can you catch multiple exceptions at once in Python?
17. What is the difference between the Exception class and the BaseException class in
Python?

Recursion
1. Write a recursive function that takes a number and returns the sum of all the numbers
from zero to that number.
2. Write a recursive function that takes a number as an input and returns the factorial of
that number.
3. Write a recursive function that takes a number ‘n’ and returns the nth number of the
Fibonacci number.
4. Write a recursive function that takes a list of numbers as an input and returns the
product of all the numbers in the list.
5. Write a function that takes a string and returns if the string is a palindrome.
6. Write a recursive function that takes a string and reverse the string.
7. Write a recursive function that takes an array that may contain more arrays in it and
returns an array with all values flattened.
8. Write a recursive function that takes an array of words and returns an array that contains
all the words capitalized.
9. Write a recursive function that will return the sum of all the positive numbers in a
dictionary which may contain more dictionaries nested in it.

Generator, Iterators
1. What is an iterator in Python?
2. What is a generator in Python?
3. What is the difference between iterators and generators in Python?
4. How do you create an iterator in Python? Can you provide an example?
5. How do you create a generator in Python? Can you provide an example?
6. What is the yield keyword in Python?
7. How do you convert a list into an iterator in Python?
8. What are the benefits of using generators and iterators in Python?
9. Can you explain how the itertools module in Python is related to iterators?
10. What happens when you call next() on an iterator or generator that has no more
elements?
11. Can you provide an example of a generator expression?
12. What is a generator function and how is it different from a normal function?

Recursion vs iteration

Operators
1. Differences between operator == and is.
Lambda Functions
1. What is a lambda function in Python?
2. Can you provide an example of when you would use a lambda function instead of a
regular function?
3. What is the syntax of a lambda function in Python?
4. Can you write a lambda function that squares a given number?
5. How do you use lambda functions with map(), filter(), and reduce() functions in Python?
6. What are the limitations of a lambda function in Python?
7. Can lambda functions have multiple inputs? If yes, can you provide an example?
8. Is it possible to have a multi-line lambda function in Python? Why or why not?
9. How do you handle exceptions in a lambda function?
10. Can you provide an example of using a lambda function within a built-in function like
sorted()?
11. What is the difference between a lambda function and a regular function in Python?
12. Can lambda functions be assigned to variables? Can you provide an example?
13. Can lambda functions be used inside list comprehensions? If yes, can you provide an
example?
14. How can you use lambda functions in conjunction with pandas DataFrame operations?

Context Managers
1. What is a context manager in Python?
2. Why would you use a context manager?
3. How can you create your own context manager?
4. What is the with statement in Python?
5. What are the arguments to the __exit__ method in a context manager?
6. Can you provide an example of a context manager in the standard library?
7. What is the contextlib module in Python?
8. Can you create a context manager using a generator function?
9. What does the @contextlib.contextmanager decorator do?
10. What is the purpose of the as keyword in the with statement?

Dictionary, Hash Maps


1. What is a dictionary in Python?
2. What is a hash map?
3. What is the relationship between dictionaries and hash maps?
4. How do you add an item to a dictionary in Python?
5. How do you remove an item from a dictionary?
6. Can dictionary keys be objects of any type?
7. What is a hash function?
8. What happens when two keys in a dictionary produce the same hash code?
9. How do you iterate over a dictionary in Python?
10. What is the time complexity of operations in a Python dictionary?
11. What is the difference between a dictionary and a list in Python?
12. Can a dictionary have multiple entries with the same value?
13. How can you merge two dictionaries in Python?

List Comprehension
1. What is list comprehension in Python?
2. How would you use list comprehension to create a list of the first ten squares?
3. Can you use list comprehension with multiple loops?
4. How can you use conditionals in list comprehension?
5. Can you use list comprehension to modify a list?
6. Is list comprehension faster than a for loop in Python? Why or why not?
7. Can list comprehension be used with data types other than lists?
8. What is a nested list comprehension?
9. What is the difference between list comprehension and generator expressions?
10. Can you provide an example of using list comprehension to filter a list?
11. How can you use list comprehension to create a dictionary?

Data Types
1. What are the basic data types in Python?
2. What is the difference between a list and a tuple?
3. What is the difference between a set and a dictionary?
4. What is the difference between mutable and immutable types in Python?
5. What is a frozenset in Python?
6. What is the purpose of the isinstance() function in Python?
7. What is an array in Python?

Async
1. Can you explain what async IO is in Python?
2. What are the advantages of using async IO over multithreading or multiprocessing?
3. How do you implement asynchronous event loops in Python?
4. Why is synchronous programming not a good idea for web applications?
5. What does await do in Python?
6. What’s the difference between coroutines and generators in Python?
7. What is an executor?
8. How do you create an executor in Python?
9. What happens if you use “async” with a function that doesn’t have the @coroutine
decorator?
10. Is it possible to write async code in python which can be run on both Python 2.7 as well
as 3.5+? If yes, then how?
11. Are there any limitations when working with AsyncIO in Python?
12. What is the best way to avoid running into race conditions while using AsyncIO?
13. Can you give me some examples where you would use AsyncIO in your application code?
14. Is it possible to call functions from a different thread when using AsyncIO? If yes, then
how?
15. What is the maximum number of threads per process in Python?
16. What is GIL? Do you think it poses a problem for multi-threaded apps written in Python?
17. What is parallelism? How does it differ from concurrency?
18. What do you understand about context switching?
19. What’s the best way to deal with blocking I/O calls in Python?
20. Can you explain what a future object is in Python?

OOP
1. What is Object-Oriented Programming (OOP)?
2. What are the four fundamental principles of OOP and explain each?
3. What is a class and what is an object in Python?
4. What are constructors in Python?
5. What is the difference between a class variable and an instance variable?
6. What is method overloading and method overriding in Python?
7. Explain the concept of inheritance and its types in Python?
8. What is a decorator in Python?
9. What is the super() function in Python?
10. What are magic methods or dunder methods in Python?

SOLID, DRY, KISS


1. What is a Python decorator and how does it relate to the Open-Closed Principle (OCP) of
SOLID?
2. Can you explain SOLID principles in the context of Python?
3. Can you explain DRY principles in the context of Python?
4. Can you explain KISS principles in the context of Python?

Design Patterns
Testing
1. What is Unit Testing in Python? Can you explain with an example?
2. What testing frameworks are you familiar with in Python?
3. How would you test a Django or Flask application?
4. Can you explain what mocking is in the context of testing? When would you use it?
5. How would you use Python's 'unittest' module to create a test case?
6. What are test suites in Python's 'unittest' module, and when would you use them?
7. What is a test fixture and how would you use it in your tests?
8. Can you explain Test-Driven Development (TDD) and its benefits?
9. What is the difference between black box testing and white box testing?
10. What is continuous integration/continuous deployment (CI/CD) and how can testing be
integrated into a CI/CD pipeline?

GIL
1. What is the Global Interpreter Lock (GIL) in Python?
2. Why does Python use the GIL?
3. How does the GIL affect multi-threading in Python?
4. What are the implications of the GIL for concurrency and parallelism in Python?
5. Can you provide an example of a situation where the GIL caused a problem and how you
handled it?
6. How can we work around the limitations imposed by the GIL?
7. Are there any plans to remove the GIL from Python?
8. What is the difference between threading and multiprocessing in Python? How does the
GIL influence this difference?

Django
General
1. Can you describe the lifecycle of a request in a Django application?
2. What is the role of Django's URL dispatcher?
3. How does Django's middleware work, and what kinds of tasks can it perform?
4. How does a Django view function process a request and generate a response?
5. What is the role of Django's Object-Relational Mapper (ORM)?
6. How does Django handle forms and form data?
7. What is the purpose of Django's template system, and how does it work?
8. How does Django handle sessions and cookies?
9. How would you deploy a Django application to a production environment?
10. What are Django signals and how can they be used?

DB

You might also like