Python | Вопросы собесов
Сайт: https://easyoffer.ru/ Все каналы: t.me/+xGeAw6ckJ4liYzQy Контакт для рекламы: @easyoffer_adv
Show more📈 Analytical overview of Telegram channel Python | Вопросы собесов
Channel Python | Вопросы собесов (@python_easy_ru) in the Russian language segment is an active participant. Currently, the community unites 12 889 subscribers, ranking 9 729 in the Technologies & Applications category and 50 792 in the Russia region.
📊 Audience metrics and dynamics
Since its creation on невідомо, the project has demonstrated rapid growth, gathering an audience of 12 889 subscribers.
According to the latest data from 01 August, 2026, the channel demonstrates stable activity. Although there has been a change in the number of participants by -117 over the last 30 days and by -4 over the last 24 hours, overall reach remains high.
- Verification status: Not verified
- Engagement rate (ER): The average audience engagement rate is 6.88%. Within the first 24 hours after publication, content typically collects 4.88% reactions from the total number of subscribers.
- Post reach: On average, each post receives 887 views. Within the first day, a publication typically gains 629 views.
- Reactions and interaction: The audience actively supports content: the average number of reactions per post is 1.
- Thematic interests: Content is focused on key topics such as ставь, модуль, строка, docker, alice.
📝 Description and content policy
The author describes the resource as a platform for expressing subjective opinions:
“Сайт: https://easyoffer.ru/
Все каналы: t.me/+xGeAw6ckJ4liYzQy
Контакт для рекламы: @easyoffer_adv”
Thanks to the high frequency of updates (latest data received on 02 August, 2026), the channel maintains relevance and a high level of publication reach. Analytics show that the audience actively interacts with content, making it an important point of influence in the Technologies & Applications category.
x = 10
print(id(x)) # 140735598722544 (адрес в памяти)
x = x + 5 # Создаётся новый объект!
print(id(x)) # 140735598722704 (новый адрес)
Пример: str неизменяемая
s = "hello"
print(id(s)) # 140735598723664
s = s + " world" # Создаётся новая строка!
print(id(s)) # 140735598724240 (новый адрес)
🚩Изменяемые (`mutable`) типы
Можно менять их содержимое без создания нового объекта.
lst = [1, 2, 3]
print(id(lst)) # 140735598722544
lst.append(4) # Изменяем список
print(id(lst)) # 140735598722544 (адрес остался тот же!)
Пример: dict изменяемый
d = {"name": "Alice"}
print(id(d)) # 140735598723664
d["age"] = 25 # Добавляем ключ
print(id(d)) # 140735598723664 (адрес не изменился!)
🚩Почему это важно?
Неизменяемые объекты безопаснее для ключей dict и set
d = {}
d[[1, 2, 3]] = "Ошибка!" # ❌ TypeError: unhashable type: 'list'
Используем tuple вместо list (он неизменяемый)
d[(1, 2, 3)] = "OK"
Ошибки с изменяемыми значениями по умолчанию
def add_item(lst=[]): # ❌ Опасный код!
lst.append(1)
return lst
print(add_item()) # [1]
print(add_item()) # [1, 1] ❌ Список не создаётся заново!
Используем None вместо списка
def add_item(lst=None):
if lst is None:
lst = []
lst.append(1)
return lst
🚩Копирование объектов (`copy()` vs `deepcopy()`)
copy() делает поверхностную копию (новый объект, но старые вложенные элементы).
deepcopy() делает глубокую копию (всё новое).
import copy
lst1 = [[1, 2, 3], [4, 5, 6]]
lst2 = copy.copy(lst1) # Поверхностная копия
lst2[0][0] = 99
print(lst1) # [[99, 2, 3], [4, 5, 6]] ❌ Исходный список изменился!
Используем deepcopy() для полной независимой копии
lst3 = copy.deepcopy(lst1)
lst3[0][0] = 100
print(lst1) # [[99, 2, 3], [4, 5, 6]] ✅ Не изменился!
Ставь 👍 и забирай 📚 Базу знанийpackage) в Python — это набор модулей, объединённых в одну директорию. Главное отличие от обычной папки — наличие файла __init__.py, который делает директорию пакетом.
🚩Как создать пакет?
Допустим, мы хотим создать пакет math_utils с модулями для работы с числами.
/my_project
/math_utils ← Это пакет
__init__.py ← Делаем директорию пакетом
arithmetic.py ← Модуль с функциями сложения/вычитания
geometry.py ← Модуль с функциями для работы с фигурами
main.py ← Основной файл программы
Код в arithmetic.py
def add(a, b):
return a + b
def subtract(a, b):
return a - b
Код в geometry.py
def square_area(side):
return side * side
Код в __init__.py
from .arithmetic import add, subtract
from .geometry import square_area
Теперь можно импортировать функции прямо из пакета:
from math_utils import add, square_area
print(add(2, 3)) # 5
print(square_area(4)) # 16
🚩Импорт модулей из пакета
Импортируем весь пакет (с __init__.py)
from math_utils import add, square_area
Импортируем конкретный модуль
from math_utils import arithmetic
print(arithmetic.add(3, 5))
Импортируем конкретную функцию из модуля
from math_utils.arithmetic import add
print(add(3, 5))
🚩Как работают пакеты в Python?
Python ищет пакеты по sys.path
import sys
print(sys.path) # Пути, где Python ищет модули
Если Python не находит пакет, можно добавить путь вручную:
import sys
sys.path.append("/path/to/my_project")
Можно создавать вложенные пакеты
/my_project
/math_utils
__init__.py
/advanced
__init__.py
calculus.py
Импорт:
from math_utils.advanced.calculus import derivative
Ставь 👍 и забирай 📚 Базу знанийimport sqlite3
conn = sqlite3.connect("example.db")
cursor = conn.cursor()
# Создаем таблицу, если её нет
cursor.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)")
# Добавляем пользователя
cursor.execute("INSERT INTO users (name) VALUES (?)", ("Алиса",))
conn.commit() # Сохраняем изменения
conn.close()
🟠Read (Чтение)
Получение данных из базы.
conn = sqlite3.connect("example.db")
cursor = conn.cursor()
cursor.execute("SELECT * FROM users")
users = cursor.fetchall() # Получаем все записи
for user in users:
print(user)
conn.close()
🟠Update (Обновление)
Изменение существующей записи.
conn = sqlite3.connect("example.db")
cursor = conn.cursor()
cursor.execute("UPDATE users SET name = ? WHERE id = ?", ("Боб", 1))
conn.commit()
conn.close()
🟠Delete (Удаление)
Удаление записи из базы.
conn = sqlite3.connect("example.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM users WHERE id = ?", (1,))
conn.commit()
conn.close()
Ставь 👍 и забирай 📚 Базу знанийBEGIN;
SELECT * FROM users WHERE id = 1 FOR UPDATE; -- Блокирует строку, пока транзакция не завершится
🟠По типу блокировки
Эксклюзивная (Exclusive, X-Lock) – блокирует запись для всех (никакие другие операции её не изменят).
Разделяемая (Shared, S-Lock) – блокирует только на запись (чтение возможно).
BEGIN;
UPDATE users SET balance = balance - 100 WHERE id = 1;
-- Пока транзакция не завершится, другая транзакция не сможет изменить balance пользователя 1.
🟠Явные и неявные блокировки
Явные (ручные) – задаются программистом (SELECT ... FOR UPDATE).
Неявные (автоматические) – создаются СУБД при INSERT, UPDATE, DELETE.
🚩Проблемы с блокировками
🟠Deadlock (взаимная блокировка)
Если два запроса ждут друг друга, система "зависает". Решение: правильный порядок выполнения транзакций.
🟠Долгие блокировки
Если транзакция не закрывается (COMMIT/ROLLBACK), другие запросы ждут бесконечно. Решение: короткие транзакции, автоматическое завершение.
🟠Снижение производительности
Чем больше блокировок, тем медленнее работа БД.
Ставь 👍 и забирай 📚 Базу знаний