Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions sprint1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#1 Задание

time_values = '1h 45m,360s,25m,30m 120s,2h 60s'
total_minutes = 0

@ShamilovR ShamilovR Jan 12, 2025

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: не хватает еще одного сплита до цикла, из за этого алгоритм работает не верно

for time in time_values:
time_items = time.split()
hours = 0
minutes = 0
seconds = 0
for item in time_items:
if 'h' in item:
hours = int(item.replace('h', ''))
elif 'm' in item:
minutes = int(item.replace('m', ''))
elif 's' in item:
seconds = int(item.replace('s', ''))
total_minutes += hours * 60
total_minutes += minutes
total_minutes += seconds / 60

print(total_minutes)


#2 Задание

class Tester:
def __init__(self, name, deadline):
self.name = name
self.deadline = deadline

def work_hard(self):
if self.deadline:
print(self.name, 'Что ж, ещё часок поработаю!')
else:
print(self.name, 'Можно отдыхать')


tester_1 = Tester(name='tester_1', deadline=False)
tester_1.work_hard() # 'tester_1 Можно отдыхать'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут тоже стоило поставить коммент, студент может исправить только указанное ниже место

tester_2 = Tester(name='tester_2', deadline=True)
tester_2.work_hard() # 'tester_2 Что ж, ещё часок поработаю!'
Comment on lines +37 to +41

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: по заданию сказано, что вызовы менять не нужно. А значит редактировать принимаемые параметры методов не нужно



#3 Задание

world_champions = {
2002: 'Бразилия',
2006: 'Италия',
2010: 'Испания',
2014: 'Германия',
2018: 'Франция',
}

world_champions[2022] = 'Аргентина'
print(world_champions.items())

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: требуется формат вывода: год - страна.


country = 'Италия'
if country in world_champions.keys():
print('Италия cтановилась чемпионом мира по футболу в 21 веке!')
else:
print('Италия не выигрывала чемпионат мира по футболу в 21 веке.')


#4 Задание

new_tasks = ['task_001', 'task_011', 'task_007', 'task_015', 'task_005']
completed_tasks = ['task_002', 'task_012', 'task_006']
completed_tasks.append(new_tasks.pop(-1))

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Можно лучше: метод pop по умолчанию берет последний элемент из списка. Если не передавать аргумент -1 то логика работы программы не изменится.

new_tasks.remove('task_007')
print('task_015')

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: в задании сказано вывести последнюю задачу на экран. В случае, когда 'task_015' не будет последней в списке алгоритм отработает не верно. Нужно использовать последний индекс



#5 Задание

class TestCase:
def __init__(self, steps=None, result=None):

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: параметр steps принимает пустой словарь, а не None

if steps is None:
steps = {}
self.steps = steps
self.result = result

def set_step(self, step_number, step_text):
self.steps[step_number] = step_text

def set_result(self, result):
result = result

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: к атрибуту экземляра класса нужно обращаться через self.


def delete_step(self, step_number, step_text: 0):
self.steps[step_number] = step_text

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Нужно исправить: данная реализация ничего не удалит, а лишь перезапишет значение по ключу. Необходимо использовать директиву del


def get_test_case(self):
test_case_info = {
'Шаги': self.steps,
'Ожидаемый результат': self.result
}
print(test_case_info)


test_case_1 = TestCase()
test_case_1.set_step(1, 'Перейти на сайт')
test_case_1.set_step(3, 'Перейти в раздел Товары')
test_case_1.delete_step(3)
test_case_1.set_step(2, 'Перейти в раздел Товары')
test_case_1.set_step(3, 'Нажать кнопку «В корзину» у первого товара')
test_case_1.set_result('Товар окажется в корзине')
test_case_1.get_test_case()

test_case_2 = TestCase()
test_case_2.set_step(1, 'Перейти на сайт')
test_case_2.set_step(2, 'Перейти в раздел Корзина')
test_case_2.set_step(3, 'Нажать кнопку "Удалить"')
test_case_2.set_result('Товар удален из корзины')
test_case_2.get_test_case()