Skip to content

Вторая домашка basic_exercises #59

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Olga888-56
Copy link

No description provided.

Copy link

@alexandrettio alexandrettio left a comment

Choose a reason for hiding this comment

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

Хорошо! Есть задание в котором надо подстроиться под текст условия, и поправить соотношение мальчиков и девочек в классе

В остальном корректно и аккуратно выполненная работа по циклам, словарям и строкам. Так держать

@@ -25,6 +27,10 @@
'Маша': False,
}
names = ['Оля', 'Петя', 'Вася', 'Маша']

Choose a reason for hiding this comment

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

Текущий код рабочий, но немного не ту задачу решает.
Нам надо пройтись по списку имен и для каждого из этих имен написать пол ученика
Можно предположить что в is_male сотни имен, а нам надо узнать только про те имена с которыми мы сталкиваемся в группе

count_groups = len(groups)
print(f"Всего {count_groups} группы")

for group_number,group in enumerate(groups, start = 1):

Choose a reason for hiding this comment

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

отлично! Отдельно хвалю за выбор имен переменных и использование enumerate

names = dict()

for student in students:
if student['first_name'] not in names.keys():

Choose a reason for hiding this comment

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

Так как мы работаем со словарем лучше сделать проверку
if student['first_name'] not in names:
Она будет работать быстрее чем
if student['first_name'] not in names.keys():

Изменения по скорости на таком маленьком объеме мы не заметим, но общий подход запомнить полезно. Для словаря наличие ключа проверяем внутри словаря, а не внутри списка ключей словаря


class_num = 1
for item in school_students:
temp = [name['first_name'] for name in item]

Choose a reason for hiding this comment

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

Здорово получилось собрать список имен из списка словарей! Горжусь тем, что ты нашла это решение

else:
girls +=1

print(f'Класс {class_name}: девочки {girls}, мальчики {boys}')

Choose a reason for hiding this comment

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

Да, как раз тот вопрос который задавала в тг. Тут получается мы выведем только для последнего класса. Потому что значения переменных пересчитываем в цикле, а выводим уже за пределами цикла

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy