-
Notifications
You must be signed in to change notification settings - Fork 262
for_challenges и for_dict_challenges на проверку #42
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
a9e8691
ddaa3e4
a90923a
4f42a44
1fc6c28
bda67dd
c4f3907
8ca0a4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,16 @@ | |
| ] | ||
|
|
||
| print('Задание 1') | ||
| qty_students = (Counter(student['first_name'] for student in students)) | ||
| for student in qty_students: | ||
| print(f'{student}: {qty_students[student]}') | ||
| # qty_students = (Counter(student['first_name'] for student in students)) | ||
| # for student in qty_students: | ||
| # print(f'{student}: {qty_students[student]}') | ||
| # print() | ||
| unique_students = [] | ||
| for student in students: | ||
| if student['first_name'] not in unique_students: | ||
| unique_students.append(student['first_name']) | ||
| for student in unique_students: | ||
| print(f"{student}: {students.count({'first_name': student})}") | ||
| print() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. |
||
|
|
||
|
|
||
|
|
@@ -134,9 +141,11 @@ | |
| else: | ||
| female[grade] += 1 | ||
|
|
||
| most_male = school[male.index(max(male))]['class'] | ||
| most_female = school[female.index(max(female))]['class'] | ||
| most_male_index = male.index(max(male)) | ||
| most_male_class = school[most_male_index]['class'] | ||
| most_female_index = female.index(max(female)) | ||
| most_female_class = school[most_female_index]['class'] | ||
| print( | ||
| f"Больше всего мальчиков в классе {most_male}") | ||
| f"Больше всего мальчиков в классе {most_male_class}") | ||
| print( | ||
| f"Больше всего девочек в классе {most_female}") | ||
| f"Больше всего девочек в классе {most_female_class}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #42 (comment) |
||
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.
#42 (comment)
Попробовал без Counter
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.
А зачем тебе отдельный unique_students, если ты можешь проверять напрямую в словаре? проверка находится ли ключ в словаре работает ощутимо быстрее, чем проверка есть ли значение в словаре