-
Notifications
You must be signed in to change notification settings - Fork 173
lesson 2 #1264
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?
lesson 2 #1264
Changes from all commits
99d87ab
773ee7f
29a0d5a
d5bca04
85272c6
530fe4f
7b65357
6a936fe
3479eaf
f2559a7
faed584
ed7c46e
150eac2
fd8f187
eb8f1c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,3 +16,21 @@ | |
| Введите число: 123 | ||
| Количество четных и нечетных цифр в числе равно: (1, 2) | ||
| """ | ||
| def count_func(numbers, even_count=0, odd_count=0): | ||
| if numbers == 0: | ||
| return even_count, odd_count | ||
| else: | ||
| even = numbers % 10 | ||
| numbers=numbers // 10 | ||
| if even % 2 == 0: | ||
| even_count += 1 | ||
| else: | ||
| odd_count += 1 | ||
| return count_func(numbers, even_count, odd_count) | ||
|
|
||
| try: | ||
| number = int(input('Введите набор цифр: ')) | ||
| except ValueError: | ||
| print('Вы ввели НЕ_число, просьба ввести именно число:') | ||
| number = int(input('Введите набор цифр: ')) | ||
| print(f'Количество чисел в вашем числе {number} по пропорции (четные, нечетные): {count_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,13 @@ | |
| Введите число, которое требуется перевернуть: 123 | ||
| Перевернутое число: 321 | ||
| """ | ||
|
|
||
|
|
||
| def rev(number,inven=0): | ||
| return inven if (number==0) else rev(number//10, inven*10 + number % 10) | ||
| try: | ||
| user_numb = int(input('Введите число: ')) | ||
| except ValueError: | ||
| print('Вы ввели буквы, а нужно ввести цифры') | ||
| user_numb = int(input('Введите число: ')) | ||
| print(f'В обратном порядке число получаются: {rev(user_numb)}') | ||
|
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 |
|---|---|---|
|
|
@@ -18,3 +18,15 @@ | |
| Решите через рекурсию. Решение через цикл не принимается. | ||
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| """ | ||
|
|
||
| def int_char(num, count, count_end): | ||
| if num == 128: | ||
| return count_end | ||
| else: | ||
| if count == 10: | ||
| return int_char(num + 1, 1, count_end + f" {num} - {chr(num)}\n") | ||
| else: | ||
| return int_char(num + 1, count + 1, count_end + f" {num} - {chr(num)}") | ||
|
|
||
|
|
||
| print(int_char(33, 1, "")) | ||
|
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,33 @@ | |
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| Для оценки Отлично в этом блоке необходимо выполнить 5 заданий из 7 | ||
| """ | ||
|
|
||
| from random import randint | ||
| print('Нужно угадать число в диапазоне от 1 до 100. У вас будет 10 попыток') | ||
|
|
||
| def riddle(numb, count=9): | ||
| if count==0: | ||
| print(f'ты НЕ_угадал! Верное число {numb}') | ||
| return | ||
| else: | ||
| number = user_numb() | ||
| if number==riddle_numb: | ||
| print(f'Ты угадал! это цифра {numb}... поздравления!') | ||
| return numb | ||
| elif number>numb: | ||
| print(f'Число {number} БОЛЬШЕ загаданного числа\nУ тебя осталось {count} попыток') | ||
| else: | ||
| print(f'Число {number} МЕНЬШЕ загаданного числа\nУ тебя осталось {count} попыток') | ||
| return riddle(numb, count-1) | ||
|
|
||
| def user_numb(): | ||
| try: | ||
| user_numb = int(input('Введите цисло: ')) | ||
| except ValueError: | ||
| print('Нужно ввести число, а не цифру') | ||
| user_numb = int(input('Введите цисло: ')) | ||
| return user_numb | ||
|
|
||
| riddle_numb= randint(1,10) | ||
|
|
||
| riddle(riddle_numb) | ||
|
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 |
|---|---|---|
|
|
@@ -10,3 +10,5 @@ | |
| то реализуйте ф-цию-декоратор и пусть она считает время | ||
| И примените ее к двум своим функциям. | ||
| """ | ||
|
|
||
| #заглушка | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,5 @@ | |
| Введите пароль еще раз для проверки: 123 | ||
| Вы ввели правильный пароль | ||
| """ | ||
|
|
||
| #lesson 3_2 заглушка | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,5 @@ | |
| р | ||
| а | ||
| """ | ||
|
|
||
| #lesson 3_3 заглушка | ||
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.
выполнено