-
Notifications
You must be signed in to change notification settings - Fork 446
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
Первые два задания на проверку #138
base: master
Are you sure you want to change the base?
Conversation
1_if1.py
Outdated
def main(): | ||
""" | ||
Эта функция вызывается автоматически при запуске скрипта в консоли | ||
В ней надо заменить pass на ваш код | ||
""" | ||
pass | ||
def activity_by_age(age): |
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.
Лучше объявить функцию activity_by_age не внутри функции main а перед ней. Тогда она будет доступна для вызова из любой части кода, а не только из функции main. В данном случае это мало на что влияет, но важно обратить внимание
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.
a6e9a6a Исправил
1_if1.py
Outdated
def activity_by_age(age): | ||
if 0 <= age <= 7: | ||
return 'Вы в детском садике' | ||
elif 7 < age <= 17: |
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.
Можно ли заменить elif на if? А почему?
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.
Думаю, что можно. Если выполнится условие, то мы выйдем из функции и программа не будет проходить по следующим проверкам. Возможно код с elif все же будет более читабельным. Больше не знаю что добавить)
1_if1.py
Outdated
def main(): | ||
""" | ||
Эта функция вызывается автоматически при запуске скрипта в консоли | ||
В ней надо заменить pass на ваш код | ||
""" | ||
pass | ||
def activity_by_age(age): | ||
if 0 <= age <= 7: |
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.
Нужно ли тут сравнение с 0 или оно избыточно? (и далее вопрос про сравнение с 7)
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.
Думаю, что 0 избыточен. 7 скорее всего тоже, но как будто так код удобнее читается. Подскажи как лучше плиз
2_if2.py
Outdated
def main(): | ||
""" | ||
Эта функция вызывается автоматически при запуске скрипта в консоли | ||
В ней надо заменить pass на ваш код | ||
""" | ||
pass | ||
|
||
def check_strings(str1, str2): |
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.
Аналогично про расположение функции
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.
4d6f8c8 забыл для исправления свой коммит написать
print(check_strings('hello', 777)) # 0 | ||
print(check_strings('hello', 'hello')) # 1 | ||
print(check_strings('hello', 'hell')) # 2 | ||
print(check_strings('hi', 'learn')) # 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.
А можешь придумать тест из 2 строк, в котором выведется на экран что-то кроме 0-1-2-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.
4d6f8c8 Приделал, сразу потребовался else :)
343, 390, 238, 437, 214, 494, 441, 518, 212, 288, 272, 247]}, | ||
] | ||
|
||
def count_sum(items_list): |
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.
здорово что написал сам! Дальше можно использовать встроенную функцию sum
3_for.py
Outdated
phone_sold_avg = int(phone['sum_sold'] / len(phone['items_sold'])) | ||
phones_sum += phone['sum_sold'] | ||
print( | ||
f"Суммарное количество продаж {phone['product']}: {phone['sum_sold']}") |
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.
Маленькая придирка. Наверно, не количество, а объем продаж
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.
79209f9 Исправил
while True: | ||
if input('Как дела? \n') == 'Хорошо': | ||
break | ||
|
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.
👍
while True: | ||
question = input('Пользователь: ') | ||
if answers_dict.get(question): | ||
print(f"Программа: {answers_dict.get(question, '')}", end='\n\n') |
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.
👍 Отлично! Не придраться
1_if1.py
Outdated
pass | ||
age = abs(int(input('Введите ваш возраст: '))) | ||
print(activity_by_age(age)) | ||
|
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.
при желании можно избавиться от функции main и перенести этот код в if name но тут на твое усмотрение уже
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.
вынес) a1c78dc
8_ephem_bot.py
Outdated
|
||
def get_constellation(update, context): | ||
user_input = context.args[0].capitalize() | ||
planet_name = { |
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.
Обычно такие справочные словари выносят из функции, так он не будет создаваться при каждом вызове функции заново и потом уничтожаться
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.
исправил 6b30a1d
else: | ||
update.message.reply_text(f'{user_input} is not a planet of solar system') | ||
|
||
planet_name[user_input].compute() |
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.
А ты тестировал свою программу с неправильными планетами? Мне кажется что надо проверить ;)
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.
Тут все супер! Пойдем к следующим задачам? |
отправляю запрос на проверку первых двух заданий