Skip to content

2. Пятина Эвелина Павловна. 613 - #43

Closed
esnvox wants to merge 7 commits into
python-department:mainfrom
esnvox:main
Closed

esnvox wants to merge 7 commits into
python-department:mainfrom
esnvox:main

Conversation

@esnvox

@esnvox esnvox commented Sep 25, 2026 •

Copy link
Copy Markdown

Домашнее задание на 26 сентября.
Домашнее задание на 2 октября.

@github-actions github-actions Bot added the 613 label Sep 25, 2026
@esnvox esnvox changed the title 1. Пятина Эвелина Павловна. 613 2. Пятина Эвелина Павловна. 613 Oct 2, 2026
Comment thread src/part1/snowflake.py
"""
# TODO: реализуйте функцию
return 0
timestamp_ms = (snowflake_id >> 22) & (2**TIMESTAMP_BITS - 1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Магические константы усложняют понимание кода.
Пункт S3, минус балл.

Comment thread src/part1/snowflake.py
# TODO: реализуйте функцию
return 0
if node_id < 0 or NODE_ID_MAX < node_id:
print(f"node_id must be in [{0}; {NODE_ID_MAX}]")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Забыли return None и ниже тоже

Comment thread src/part1/snowflake.py
if node_id < 0 or NODE_ID_MAX < node_id:
print(f"node_id must be in [{0}; {NODE_ID_MAX}]")

if 0 < sequence_id or sequence_id < SEQUENCE_ID_MAX:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут как будто знак больше должен быть:

0 < sequence_id or sequence_id > SEQUENCE_ID_MAX

Comment thread src/part2/cart.py
index = 0
for line in cart:
if line[LINE_PRODUCT_ID_INDEX] == product_id:
updated_product = (product_id, line[LINE_PRODUCT_ID_INDEX] + quantity)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы используете LINE_PRODUCT_ID_INDEX, а это индекс id продукта, а не индекс количества

Comment thread src/part2/cart.py
for line in cart:
if line[LINE_PRODUCT_ID_INDEX] == product_id:
updated_product = (product_id, line[LINE_PRODUCT_ID_INDEX] + quantity)
cart[index] = updated_product

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется вы не меняете index, и он у вас всегда 0

Comment thread src/part2/cart.py
for index in range(len(cart)):
if cart[index][LINE_PRODUCT_ID_INDEX] == product_id:
if new_quantity == 0:
del cart[index]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это уже вкусовщина, но мне больше нравится удалять через cart.pop(index)

Comment thread src/part2/crud.py
# TODO: реализуйте функцию
return (0, "", Decimal(0), 0)

for index, product in enumerate(storage):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Цикл:

for index, product in enumerate(storage):
        if product[PRODUCT_ID_INDEX] == product_id:

встречается 3 раза, лучше было бы поиск вынести в отдельную функцию. Код был бы понятнее.
Пункт S1

Comment thread src/part2/crud.py
for product in storage:
if product[PRODUCT_ID_INDEX] == product_id:
return product
print(f"no product with id {product_id}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сообщение пишется каждую итерацию

@esnvox esnvox closed this Nov 1, 2026
@esnvox esnvox reopened this Nov 1, 2026
@esnvox esnvox closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants