Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Maksimous777
Copy link

отправляю запрос на проверку первых двух заданий

1_if1.py Outdated
def main():
"""
Эта функция вызывается автоматически при запуске скрипта в консоли
В ней надо заменить pass на ваш код
"""
pass
def activity_by_age(age):

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. В данном случае это мало на что влияет, но важно обратить внимание

Copy link
Author

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:

Choose a reason for hiding this comment

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

Можно ли заменить elif на if? А почему?

Copy link
Author

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:

Choose a reason for hiding this comment

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

Нужно ли тут сравнение с 0 или оно избыточно? (и далее вопрос про сравнение с 7)

Copy link
Author

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):

Choose a reason for hiding this comment

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

Аналогично про расположение функции

Copy link
Author

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

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
Это очень полезное упражнение :)

Copy link
Author

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):

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']}")

Choose a reason for hiding this comment

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

Маленькая придирка. Наверно, не количество, а объем продаж

Copy link
Author

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

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')

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))

Choose a reason for hiding this comment

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

при желании можно избавиться от функции main и перенести этот код в if name но тут на твое усмотрение уже

Copy link
Author

@Maksimous777 Maksimous777 Jun 2, 2023

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 = {

Choose a reason for hiding this comment

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

Обычно такие справочные словари выносят из функции, так он не будет создаваться при каждом вызове функции заново и потом уничтожаться

Copy link
Author

@Maksimous777 Maksimous777 Jun 2, 2023

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()

Choose a reason for hiding this comment

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

А ты тестировал свою программу с неправильными планетами? Мне кажется что надо проверить ;)

Copy link
Author

Choose a reason for hiding this comment

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

Да, все работает)
image

@alexandrettio
Copy link

Тут все супер! Пойдем к следующим задачам?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants