-
Notifications
You must be signed in to change notification settings - Fork 448
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
Homework_1_Glazunova #173
base: master
Are you sure you want to change the base?
Homework_1_Glazunova #173
Conversation
…ужно доделать землю, убрать чувствительность к регистру, что-то сделать с датой
1_if1.py
Outdated
def main(age): | ||
if age >= 2 and age < 7: | ||
return "Детский сад" | ||
elif age >= 7 and age < 18: |
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 age >= 7 and age < 18:
на
elif age < 18:
Почему?
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.
А если age = 1? :)
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>=2 - не верно, поэтому в садик не попадаем, зато однозначно <18, поэтому школа как раз подходит)) исправила, как было.
1_if1.py
Outdated
@@ -14,12 +14,28 @@ | |||
|
|||
""" | |||
|
|||
def main(): | |||
""" | |||
def main(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.
Давай переназовем функцию для понятности что она делает
age = int(age_in) | ||
activity = main(age) | ||
print(f"Ваше занятие по возрасту {activity}") | ||
input () |
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.
👍
print(main ("text","123")) | ||
print(main("text","text")) | ||
print(main("texttexttext", "text")) | ||
print(main("text","learn")) |
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.
👍 отлично!
print(f'суммарное количество продаж {all_sales}') | ||
print(f'среднее количество продаж {avg_all_sales}') | ||
|
||
main(data) |
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.
Супер! Аккуратное выполнение
5_while2.py
Outdated
if question in questions_and_answers: | ||
print(answer) | ||
else: | ||
print("я не знаю") |
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.
Да, это рабочий вариант. Давай для тренировки избавимся от if-else и попробуем переписать через .get(...)
else: | ||
print('Как дела? ') | ||
except KeyboardInterrupt: | ||
print('Пока!') |
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.
👍
7_exception2.py
Outdated
print(discounted(100.0, 5, "10")) | ||
try: | ||
price = abs(price) | ||
price = float(price) |
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.
Можно такие действия объединять
price = float(abs(price))
Или же надо давать разные имена на разных шагах. На самом деле мы стараемся не экономить на именах иначе создается ситуация в которой в разных местах программы под одним именем разные по логике вещи и
raw_price = abs(price)
price = float(raw_price)
7_exception2.py
Outdated
else: | ||
price_with_discount = price - (price * discount / 100) | ||
return price_with_discount | ||
except(ValueError, TypeError): |
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.
Сейчас у тебя блок except слишком низко.
В итоге сообщение "Максимальная скидка не должна быть больше 100" ты никогда не увидишь так как его сама же перехватишь и заменишь на "Не сработало приведение типов"
Попробуй переместить аккуратно и проверить что приведение типов обрабатывается корректно и max_discount >=100 выдавал свою ошибку
8_ephem_bot.py
Outdated
planet_name = planet.split() | ||
print(planet_name) | ||
name = planet_name[1] | ||
Mars = ephem.Mars("2024/11/30") |
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.
А давай заменим "2024/11/30" на переменную отвечающую за текущую дату
…ение планет бралось на текущую дату
No description provided.