Skip to content
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0f1e138
basic_exercises part 1
Feb 20, 2023
1c8d7d0
basic_exercises fixed
Feb 22, 2023
88169bb
basic_exercises fixed_1
Feb 22, 2023
190192d
add string_challenges.py, for_challenges.py fixed
Feb 23, 2023
85ef5fb
add for_dict_challenges.py
Feb 25, 2023
c27c417
for_challenges.py, string_challenges.py fixed
Feb 25, 2023
dd92056
add task company.py solution
Feb 26, 2023
c63c919
add task company.py solution
Feb 26, 2023
b3ba249
company.py fixed, add additional tasks
Feb 27, 2023
867a711
fixed compane.py
Feb 28, 2023
991276a
fixed company.py, for_dict_challenges.py +last task
Mar 1, 2023
7ff8a37
fixed company.py
Mar 3, 2023
1a2b535
fixed for_dict_challenges.py, except for the 5 task
Mar 3, 2023
d7696ae
fixed company.py, for_dict_challenges.py
Mar 4, 2023
1a9d3bc
fixed for_challenges.py, string_challenges.py
Mar 4, 2023
2c3c060
correcting remarks code review company.py, for_dict_challenges.py
Mar 5, 2023
0563d48
add task 13, 14 company
Mar 6, 2023
f4da86c
correcting task 13, add functions
Mar 9, 2023
9b7131c
fixed 13, 14 tasks
Mar 11, 2023
0b79ba6
Исправил замечания, добавил решения задач 16,17,18
Mar 18, 2023
7598ae9
Решение 1 задачи в for_dict_challenges_bonus.py
Mar 18, 2023
fb5366d
исправление замечаний review
Mar 19, 2023
191c915
исправление замечаний, немного поменял алгоритм
Mar 19, 2023
3cc58b3
fixing the mistakes according to the comments
Mar 21, 2023
3aa9ea8
Решение 2 задачи \for_dict_challenges_bonus.py
Mar 27, 2023
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
23 changes: 14 additions & 9 deletions company_add_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ def output_departments_name_by_total_taxes(departments_salary, department_taxes)
tax_burden = departments_salary.get(department) * department_taxes.get(department)
departments_total_taxes[department] = tax_burden

sorted_departments_total_taxes = dict(sorted(departments_total_taxes.items(), key=lambda item: item[1],
reverse=True))
departments_names_by_total_taxes = [department_name for department_name in sorted_departments_total_taxes]
departments_names_by_total_taxes = list(sorted(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

В list не надо превращать.

departments_total_taxes,
key=departments_total_taxes.get,
reverse=True,
))

for department_name in departments_names_by_total_taxes:
print(department_name)

Expand All @@ -124,7 +127,7 @@ def output_employers_over_option_tax(departments, option_sum_of_tax):
employer_year_tax = employer['salary_rub'] * 12 * tax_of_departments[department["title"]]
if employer_year_tax > option_sum_of_tax:
print(f'За {employer["first_name"]} {employer["last_name"]} компания платит больше '
f'{option_sum_of_tax//1000} тысяч налогов в год')
f'{option_sum_of_tax // 1000} тысяч налогов в год')


# task 18. Вывести имя и фамилию сотрудника, за которого компания платит меньше всего налогов.
Expand All @@ -135,14 +138,16 @@ def get_employer_with_max_tax(departments):
for employer in department['employers']:
employers_taxes = {}
employer_year_tax = employer['salary_rub'] * 12 * tax_of_departments[department["title"]]
employers_taxes["first_name"] = employer["first_name"]
employers_taxes["last_name"] = employer["last_name"]
employers_taxes["year_tax"] = employer_year_tax
employers_taxes = {
"first_name": employer["first_name"],
"last_name": employer["last_name"],
"year_tax": employer_year_tax,
}
employers_taxes_list.append(employers_taxes)

sorted_list_of_employers_tax = sorted(employers_taxes_list, key=lambda x: x["year_tax"], reverse=True)
employer_with_max_tax = max(employers_taxes_list, key=lambda x: x["year_tax"])

return sorted_list_of_employers_tax[0]["first_name"], sorted_list_of_employers_tax[0]["last_name"]
return employer_with_max_tax.get("first_name"), employer_with_max_tax.get("last_name")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Тут get лишние: ты ж знаешь, что в employer_with_max_tax точно есть эти ключи, так что используй квадратные скобки.



if __name__ == "__main__":
Expand Down