-
Notifications
You must be signed in to change notification settings - Fork 173
Dz2 #1277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Dz2 #1277
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,5 @@ | |
|
|
||
| После реализации структуры, проверьте ее работу на различных сценариях | ||
| """ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,20 @@ | |
| Введите число: 123 | ||
| Количество четных и нечетных цифр в числе равно: (1, 2) | ||
| """ | ||
|
|
||
|
|
||
| def func(number, even_number=0, not_even=0): | ||
| if number == 0: | ||
| return even_number, not_even | ||
| else: | ||
| numb = number % 10 | ||
| number = number // 10 | ||
| if numb % 2 == 0: | ||
| even_number += 1 | ||
| else: | ||
| not_even += 1 | ||
| return func(number, even_number, not_even) | ||
|
|
||
|
|
||
| number = int(input(' Введите число: ')) | ||
| print(f'Количество четных и нечетных цифр в числе равно: {func(number)}') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,10 @@ | |
| Введите число, которое требуется перевернуть: 123 | ||
| Перевернутое число: 321 | ||
| """ | ||
|
|
||
| def revers_numb(number): | ||
| return str(number) if number < 10 else str(number % 10) + revers_numb(number // 10) | ||
|
|
||
|
|
||
| number = int(input("Введите число: ")) | ||
| print(revers_numb(number)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,9 @@ | |
| Решите через рекурсию. Решение через цикл не принимается. | ||
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| """ | ||
| def func(number): | ||
| return 0 if number == 0 else 1 + func(number - 1) / - 2 | ||
|
|
||
|
|
||
| count = int(input('Введите количество элементов: ')) | ||
| print(f'Количество элементов - {count}, их сумма - {func(count)}') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,19 @@ | |
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| """ | ||
| import random | ||
| def func(count, number): | ||
|
|
||
| print(f'Попытка {count}') | ||
| user_number = int(input('Введите число от 0 до 100: ')) | ||
| if count == 10 or user_number == number: | ||
| if user_number == number: | ||
| print("Верно!") | ||
| print(f"Загаданное число: {number}") | ||
| else: | ||
| if user_number > number: | ||
| print('Загаданное число меньше') | ||
| else: | ||
| print('Загаданное число больше') | ||
| func(count + 1, number) | ||
| func(1, random.randint(0, 100)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено как в примере |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
валидацию делать нужно
иначе будет ошибка