Contents:
- About the popularity of Python
- Knowledge of syntax and basic constructs
- Working with data types and their conversion
- Algorithms and Data Structure
- Modular and Object-Oriented Architecture
- Working with Files and Databases
- Parallelism and Multithreading
- Python Tools and Libraries
- Code Testing and Debugging
- Useful Materials from the Skillbox.by Editorial Team
About the Popularity of Python
Many programmers apply for the position of Python developer. And the competition in IT is only intensifying. According to IBS, there are about 10 resumes for every Python vacancy.
To successfully pass the interview, you need to prepare and know what the interviewer will ask. Companies use technical questions to evaluate a candidate's understanding of the language and skills.
Python is also one of the most popular programming languages. According to the TOIBE index, it ranks first, just like last year.It ranks first, just like last year.

The programming language is used in web application development, data analysis, and process automation.
During interviews, companies want to see candidates who are able to solve problems and apply knowledge in their work. You need to be prepared for different types of questions: from algorithmic problems to questions about specific Python libraries and tools.
The Skillbox.by editorial team has analyzed frequently asked interview questions that will help you prepare for your interview.

This course is for those who dream of working in IT but don't know where to start or are worried about failing.
Learn MoreKnowledge of Syntax and Basic Constructs
During Python developer interviews, interviewers pay special attention to the basic constructs of the language. This allows them to assess fundamental programming skills and the ability to solve problems using basic elements. Below are the topics and questions that are often covered in interviews.
- Variables and Data Types.
Interviewers ask about the differences between data types in Python, such as numbers - integers and floats, text strings and lists. You need to understand how to properly create variables and use them, what operations can be performed on each data type.
📌 Example question on this topic
Question: What data types does Python support and how to create variables with these types?
Answer: Python supports several built-in data types: numbers - integers and floating point, strings, lists, tuples, sets, dictionaries, and booleans.
Example code with different data types:
# Numbers
number = 42
float_num = 3.14
# Lines
text = «Hello»
# Lists
my_list = [1, 2, 3]
# Tuples
my_tuple = (1, 2, 3)
# Sets
my_set = {1, 2, 3}
# Dictionaries
my_dict = {«key»: «value»}
# Boolean type
is_active = True
- Loops and Iterations.
Questions about loops often test your ability to use the ‘for’ and ‘while’ constructs. They may involve iterating over lists or other collections of data. The objective is to demonstrate an understanding of how to control the iteration process and the correct use of loop exit conditions.
📌 Example question on this topic
Question:How to use the ‘for’ and ‘while’ loops in Python. And when should I use each one?
Answer:‘for’ loops are used to iterate over elements in collections, such as lists or strings. For example: for item in items: print(item). The while loop is used when you need to repeat actions until a certain condition is met: while condition: do_something(). It is important to be able to control the repetition process and use loop exit conditions correctly.
- Conditional Statements.
Interviewers may test your ability to use conditional statements: ‘if’, ‘elif’, and ‘else’ to define program logic. For example, ask how to correctly construct conditions and what to consider to avoid errors in logic.
📌 Example question on this topic
Question: How to correctly use the ‘if’, ‘elif’ and ‘else’ constructs in Python?
Answer: The if, elif, and else statements help control program logic by allowing code to be executed based on conditions.
Code example:
if condition1:
do_something()
elif condition2:
do_something_else()
else:
do_default_thing()
It is important to construct conditions correctly to avoid errors in the logic of the program.
- Working with dictionaries. Interviews often ask questions about methods for adding, deleting, or updating items in a dictionary.
📌 Example question on this topic
Question: how to work with dictionary items in Python?
Answer:
# Create a dictionary
user = {‘name’: ‘John’, ‘age’: 25}
# Add an element
user[‘city’] = ‘New York’
# Changing element
user[‘age’] = 26
# Removing an element
del user[‘name’]
# Removing using pop()
city = user.pop(‘city’)
print(user) # Outputs: {‘age’: 26}
- Functions and their use.These questions help determine the candidate's understanding of how to define and call functions. The interviewer can also test their ability to pass arguments and return values.
📌 Example question on this topic
Question:How do I define and call functions in Python?
Answer:To create a function, use the ‘def’ keyword, then call it by name. For example:
def greet(name):
return f»Hello, {name}!»
print(greet(«Maria»))
- Python Syntax and Peculiarities.Questions about syntax, such as the importance of indentation, are asked to test knowledge of specific language features. Errors due to incorrect code formatting are a common problem, so it is important to know this topic as well.
📌 Example question on this topic
Question: Why is indentation important in Python?
Answer: Indentation in Python determines the structure of a program. Incorrect code formatting can lead to errors. Strict indentation rules must be followed to maintain the readability and correctness of the program.
Working with Data Types and Their Conversion
Knowledge of data types is tested in interviews because they are the foundation of programming. Here are the main types covered in interviews:
- Strings.Strings are a simple data type for storing text information. Interviewers ask how to perform operations with substrings or change the case of letters. The topic of encoding, which affects the processing of text data, is often touched on.
- Lists.During the interview, the candidate is asked how to manage lists: adding and removing elements, sorting data. Knowledge of list methods and how to iterate over their elements is often tested in interviews for the position of Python developer.
- Tuples.Although tuples are similar to lists, their main difference is immutability. Candidates are asked when it is better to use tuples instead of lists. For example, for change-proof data sets.
- Dictionaries.Dictionaries allow you to store data as key-value pairs. The interviewer may ask about ways to access data and check for the presence of certain keys. Understanding how dictionaries work and how they differ from lists and tuples is important for the candidate.
- Sets.Sets are collections of unique elements. The interviewer may ask about set operations: union and intersection. It is important to know in what situations sets help optimize code.
When discussing data types, interviewers ask about converting one type to another. This includes converting from lists to tuples or from strings to sets. Each transformation has its own nuances and pitfalls that you should be familiar with.
Pay attention to learning simple, clear examples for each data type. This will help reinforce the material and give you confidence in the interview.
📌 Sample question on this topic
Question: What is the difference between a list, tuple, and set in Python?
Answer:
# List — mutable, ordered, with duplicates
numbers_list = [1, 2, 2, 3]
numbers_list[0] = 5 # Elements can be modified
# Tuple — immutable, ordered, with duplicates
numbers_tuple = (1, 2, 2, 3)
# numbers_tuple[0] = 5 # Elements cannot be modified
# Set — mutable, unordered, no duplicates
numbers_set = {1, 2, 2, 3} # Will be {1, 2, 3}
numbers_set.add(4) # Can add elements
print(numbers_list) # [5, 2, 2, 3]
print(numbers_tuple) # (1, 2, 2, 3)
print(numbers_set) # {1, 2, 3, 4}
📌 Example question on this topic
Question:How do I convert a dictionary to a set in Python?
Answer: Python's built-in methods are used to convert a dictionary to a set. When converting to a set, only dictionary keys are preserved.
Code example:
my_dict = {‘a’: 1, ‘b’: 2, ‘c’: 3}
my_set = set(my_dict)
print(my_set) # Output: {‘a’, ‘b’, ‘c’}
To get a set of values:
values_set = set(my_dict.values())
print(values_set) # Output: {1, 2, 3}
Algorithms and Data Structure
Candidates are asked questions related to basic algorithms and data structures. These topics help assess programming skills and the candidate's understanding of computational processes.
- Sorting and Searching Algorithms. Interviewers ask about bubble sort, insertion sort, and quicksort.Algorithms test theory and assess the candidate's ability to apply knowledge in practice. The choice of algorithm depends on the context. For example, quicksort is suitable for large data sets.
📌 Example question on this topic
Question: In what case would you use merge sort instead of quicksort?
Answer: Merge sort makes sense to use when sorting stability is important. Namely, when you need to preserve the order of identical elements. Sorting is also suitable for large data that does not fit in RAM, since it works on the principle of dividing the data into parts and processing them. It has the same worst-case complexity as the average-case sort — O(n log n), unlike quicksort, which has O(n^2) worst-case complexity.
📌 Example question on this topic
Question: What are the main differences between bubble sort and quicksort?
Answer: Bubble sort is a simple algorithm that compares pairs of adjacent elements and swaps them if they are in the wrong order. This continues until the entire array is sorted.
Sorting has a time complexity of O(n^2), which makes it inefficient for large arrays. Quicksort, on the other hand, uses the divide-and-conquer principle, breaking the array into subarrays and sorting them recursively. Its average time complexity is O(n log n), which makes it suitable for large data.
- Practice.In addition to theory, the interviewer may ask the candidate to demonstrate how to apply algorithms and data structures in practice. For example, he/she may ask to implement a simple sort or search in an array in real time.
Modular and Object-Oriented Architecture
Modules and packages are tools that help organize your code. Knowing this allows you to effectively manage your code and divide tasks into small, understandable parts.
💡 A module is a file with the .py extension that contains Python code that can be used in other programs.
💡 A package is a directory containing modules and special-purpose files.
Object-oriented programming is a programming style that organizes program code around "objects." Objects can contain data and methods for working with this data.
Understanding OOP principles is important when creating complex programs that require clear structure and easy code maintenance. Using OOP simplifies development, makes code flexible and easy to change.
An interview may test a candidate's ability to determine which classes and methods are needed to solve a practical problem, how inheritance can be used to improve program structure, or how encapsulation works. The purpose of these questions is to find out if the candidate has the skills that will help him work on Python projects.
📌 Example question on this topic
Question:What is encapsulation in Python and how is it implemented?
Answer:Encapsulation is a principle that involves hiding the internal state of an object and restricting access to its data. In Python, encapsulation is achieved using private methods and attributes.
Example code with encapsulation:
class Employee:
def __init__(self, salary):
self.__salary = salary
@property
def salary(self):
return self.__salary
@salary.setter
def salary(self, value):
if value > 0:
self.__salary = value
worker = Employee(5000)
print(worker.salary)
worker.salary = 6000
📌 Example of a question for this topic
Question:How to implement polymorphism in Python?
Answer:Polymorphism allows objects of different classes to handle calls to methods of the same name in their own way. In Python, this is achieved by using methods with the same name in different classes.
Example code:
class Bird:
def fly(self):
return «Flying»
class Airplane:
def fly(self):
return «Soaring through the sky»
def perform_fly(entity):
print(entity.fly())
bird = Bird()
airplane = Airplane()
perform_fly(bird) # Outputs «Flying»
perform_fly(airplane)
📌 Example question on this topic
Question: What classes and methods would you create to implement a simple library management program?
Answer: A Book class that contains attributes: book title, author, and ISBN. A Library class would manage a collection of books, with methods for adding, deleting, and searching for books. It is important to apply encapsulation so that methods can interact only with the necessary attributes.
Working with Files and Databases
You need to know how a programming language allows you to manage files for reading and writing data.
- Working with Files. In Python, files are read and written using the built-in functions open, read, write, and close. A try-except block is used to handle errors that occur when working with files. This helps avoid program crashes and maintain data integrity.
- Databases.Python supports working with databases through libraries such as SQLite or PostgreSQL.
SQLite is a built-in database that does not require a separate server to run. Suitable for small projects and simple testing.
PostgreSQL is a powerful database with support for various functions. The psycopg2 library is used to work with it.
The interview may include questions about establishing a connection to the database, executing queries, and processing the results. You should also be prepared for questions about data security. For example, about the use of encryption and database access control.
Understanding exceptions and data security is also a common question. Interviewers ask about SQL injection protection and proper password management.
📌 Example question on this topic
Question: How do I connect to a PostgreSQL database using Python?
Answer: Using the psycopg2 library to interact with PostgreSQL from Python. The connection is established through the connect() function, where the connection parameters are passed.
Code example:
import psycopg2
try:
connection = psycopg2.connect(
dbname=»your_dbname»,
user=»your_username»,
password=»your_password»,
host=»localhost»,
port=»5432″
)
cursor = connection.cursor()
cursor.execute(«SELECT version();»)
db_version = cursor.fetchone()
print(f»Connected to: {db_version}»)
except Exception as error:
print(f»Error: {error}»)
finally:
if connection:
cursor.close()
connection.close()
📌 Example of a question on this topic
Question: What security measures should be taken when working with databases to protect data from SQL injection attacks?
Answer: Three methods - stored procedures, access rights restrictions, and input data validation.
- Stored procedures are pre-created and validated queries that are called through the API: cursor.callproc(‘get_user’, [user_id]).
- Access Rights Restriction — each user is given only the necessary privileges in the database.
- Input Data Validation — checking and cleaning all data received from the user.
Parallelism and Multithreading
The most popular questions are about parallel processing and multithreading. This is due to the importance of efficient use of computer resources when executing programs.
Parallelismis a technique in which several tasks are executed simultaneously to speed up the process.
Multithreadingis the principle of parallel execution of several tasks within a single application with a shared memory space. In operating systems, threads run simultaneously due to fast switching between them at the processor level.
To work with parallelism in Python, two modules are used: threading and multiprocessing. The threading module allows you to create multiple threads in a single program.
The multiprocessing module differs from threading in that it creates separate processes for performing tasks. This is a safe approach, since each process has its own memory and does not interfere with others. Thus, synchronization issues are less common.
During interviews, you are often asked to explain the difference between these modules and describe their use cases. For example, threading is suitable for tasks that can be performed in parts, such as downloading files. And multiprocessing is for heavy calculations when you need to use the capabilities of all processor cores.
📌 Example question on this topic
Question:What is the difference between the threading and multiprocessing modules in Python? When should they be used?
Answer:The threading module in Python is used to work with threads. It helps create and manage them, synchronize and organize their interactions. It is suitable for tasks that can be performed in parts and copes well with I/O tasks.
Multiprocessing, on the other hand, creates separate processes that use their own memory. The module is suitable for tasks that require the use of all processor cores and where the security of process isolation is important.
Example code for threading:
import threading
def print_numbers():
for i in range(5):
print(f’Number: {i}’)
thread = threading.Thread(target=print_numbers)
thread.start()
thread.join()
Example code for multiprocessing:
from multiprocessing import Process
def print_numbers():
for i in range(5):
print(f’Number: {i}’)
process = Process(target=print_numbers)
process.start()
process.join()
📌 Example question on this topic
Question: What difficulties can arise when using threading in Python?
Answer: The main difficulty is that multiple threads access shared resources, which can lead to synchronization issues. Sometimes this causes errors - data races, which complicate debugging and lead to unpredictable program behavior.
Python Tools and Libraries
The interviewer's main task is to assess how well the candidate is familiar with NumPy, pandas, Flask, or Django libraries:
- NumPy and pandas.These libraries are used to work with data. Interviewers expect candidates to explain how NumPy helps with array processing and mathematical operations, and how pandas helps with data structuring and analysis.
- Flask and Django.Knowledge of web frameworks is useful for developing web applications. Flask is easy to learn and allows for quick prototyping. Django offers a comprehensive solution with built-in functions for the user.
The candidate should explain when and why to use this or that library.
📌 Example question on this topic
Question: What is the difference between NumPy and pandas? Give an example of their use.
Answer: NumPy is a library for working with multidimensional arrays, matrices, and mathematical functions. Pandas is used to work with tabular data and provides data structures and functions for manipulating it efficiently.
For example, NumPy is often used for numerical operations and linear algebra. And pandas makes it easy to import, analyze, and process data from tables.
Code example:
import numpy as np
import pandas as pd
# NumPy example
array = np.array([1, 2, 3, 4])
print(«NumPy array:», array * 2) # Multiply all array elements by 2
# pandas example
data = {‘Name’: [‘John’, ‘Anna’, ‘Peter’], ‘Age’: [28, 24, 35]}
df = pd.DataFrame(data)
print(«DataFrame:\n», df)
📌 Example question on this topic
Question: What is the advantage of Flask over Django and in what situation would you use Flask?
Answer:Flask is a lightweight web framework that provides a minimal set of tools for building web applications. It is ideal for creating small and simple prototypes where only basic functionality is needed.
Django, on the other hand, provides a comprehensive solution with various built-in functions, which makes it more suitable for larger and more complex projects.
Flask code example:
from flask import Flask
app = Flask(__name__)
@app.route(‘/’)
def hello_world():
return ‘Hello, World!’
if __name__ == ‘__main__’:
app.run()
📌 Example question on this topic
Question: how to create a time series with pandas and calculate the moving average average?
Answer: The pandas package is suitable for working with time series. You can create a time series using pd.date_range(). To calculate the moving average, you can use the .rolling() method.
Code example:
import pandas as pd
# Creating a time series
dates = pd.date_range(start=’2023-01-01′, periods=5)
data = [10, 20, 15, 25, 30]
series = pd.Series(data, index=dates)
# Calculation of the moving average average
rolling_mean = series.rolling(window=2).mean()
print(«Series:\n», series)
print(«Rolling average:\n», rolling_mean)
Testing and debugging code
Testing and debugging helps ensure that your code works correctly and without errors. Candidates should be familiar with the main testing tools: unittest and pytest. They help automate code checking. For example, unittest is a built-in Python module that provides functionality for creating tests. pytest is a powerful tool that simplifies the testing process and allows you to write compact and understandable tests.
During an interview, you will need to be able to find and fix errors in your code. Candidates should explain in simple terms how they identify a bug and what steps they take to fix it. For example, using debugging techniques or output from unittest and pytest tests.
They should also demonstrate an understanding of the debugging process. For example, the ability to determine the cause of a problem and propose effective solutions. The ability to explain their actions and approach to solving the problem will be a plus for the candidate.
📌 Example question on this topic
Question:How can I use unittest to test a function that returns the square of a number?
Answer:
import unittest
def square(x):
return x * x
class TestSquareFunction(unittest.TestCase):
def test_square(self):
self.assertEqual(square(2), 4)
self.assertEqual(square(-3), 9)
self.assertEqual(square(0), 0)
if __name__ == ‘__main__’:
unittest.main()
📌 Example question on this topic
Question: How can I test that a function raises an exception in pytest?
Answer: Pytest offers a special way to test that a function raises exceptions using the pytest.raises construct.
Example code:
import pytest
def divide(x, y):
if y == 0:
raise ValueError(«Cannot divide by zero!»)
return x / y
def test_divide_zero():
with pytest.raises(ValueError, match=»Cannot divide by zero!»):
divide(10, 0)
📌 Example question on this topic
Question: How can I debug a function using Python's built-in tools?
Answer: Python provides the pdb module for built-in debugging. With it, you can step through code line by line, view variable values, and monitor program flow.
Code example:
def buggy_function(x, y):
import pdb; pdb.set_trace() # Setting a breakpoint
result = x + y
return result
buggy_function(4, ‘2’) # Suspected error due to addition of a number and a string
Useful materials from the editors of Skillbox.by
These are suitable for in-depth preparation for an interview for the position of Python developer Materials:
- List of questions from interviews for data scientists with answers from VK Cloud.
- A large list of questions and answers to them, divided into categories.
- Questions, divided into levels: Junior, Middle and Senior.
Take the course "Start in DevOps: System Administration for Beginners"
You Learn to administer Linux, configure web servers, and maintain websites. You can start a career as a system administrator and gain basic knowledge for development in DevOps engineering.
Remove access
