Skip to content

For challenges#1

Open
PetrovSt89 wants to merge 5 commits intomainfrom
for_challenges
Open

For challenges#1
PetrovSt89 wants to merge 5 commits intomainfrom
for_challenges

Conversation

@PetrovSt89
Copy link
Copy Markdown
Owner

No description provided.

names = ['Оля', 'Петя', 'Вася', 'Маша']
# ???
for name1 in names:
print(name1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

names = ['Оля', 'Петя', 'Вася', 'Маша']
# ???

for name3 in names:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 можно не менять названия переменным и использовать тот же name

names = ['Оля', 'Петя', 'Вася', 'Маша']
# ???
for name in names:
if is_male[name] == False:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 еще можешь использовать тернарный оператор:

gender = 'мужской' if is_male[name] else 'женский'

['Оля', 'Петя', 'Гриша'],
]
# ???
for group in range(1,len(groups)+1):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 хорошее решение, есть еще попроще метод (а мы такие любим):

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

]
# ??? No newline at end of file
for name in range(len(groups)):
names = ', '.join(groups[name])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

]
# ???
repeat = diction_name_count(students)
def max_name(diction):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Непонятно без контекста, что там в этом diction

repeat = diction_name_count(students)
def max_name(diction):
max_count = 0
for name,count in diction.items():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 реализация верная

# ???

for classes in range(len(school_students)):
print(f'Самое частое имя в классе {classes+1}: {max_name(diction_name_count(school_students[classes]))} ')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 очень здорово, что пользуешься переиспользованием функций
💡 тут лучше бы зашел str.format, а не f-strings

for n in student:
name = n['first_name']
if is_male[name] == True:
boys.append(name)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

count_boys = len(boys)
count_girls = len(girls)

if count_boys > clas_count_boys:
Copy link
Copy Markdown

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