-
Notifications
You must be signed in to change notification settings - Fork 262
Problem solution #30
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?
Problem solution #30
Changes from 1 commit
0f1e138
1c8d7d0
88169bb
190192d
85ef5fb
c27c417
dd92056
c63c919
b3ba249
867a711
991276a
7ff8a37
1a2b535
d7696ae
1a9d3bc
2c3c060
0563d48
f4da86c
9b7131c
0b79ba6
7598ae9
fb5366d
191c915
3cc58b3
3aa9ea8
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 |
|---|---|---|
|
|
@@ -32,7 +32,7 @@ | |
| ] | ||
|
|
||
| def max_name(students): | ||
| name_of_students = [students[name]['first_name'] for name in range(len(students))] | ||
| name_of_students = [student['first_name'] for student in students] | ||
|
|
||
| names_counter = dict() | ||
| for name in name_of_students: | ||
|
|
@@ -118,7 +118,6 @@ def max_name(students): | |
| school = [ | ||
| {'class': '2a', 'students': [{'first_name': 'Маша'}, {'first_name': 'Оля'}]}, | ||
| {'class': '3c', 'students': [{'first_name': 'Олег'}, {'first_name': 'Миша'}]}, | ||
| {'class': '4c', 'students': [{'first_name': 'Олег'}, {'first_name': 'Миша'}, {'first_name': 'Миша'}]}, | ||
| ] | ||
| is_male = { | ||
| 'Маша': False, | ||
|
|
@@ -127,6 +126,11 @@ def max_name(students): | |
| 'Миша': True, | ||
| } | ||
|
|
||
| max_male_class = '' | ||
| max_female_class = '' | ||
|
Contributor
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. Пока у тебя нет таких классов, в эти переменные стоит записывать None – его в пайтоне как раз для этого и придумали. |
||
| max_male_gender = 0 | ||
| max_female_gender = 0 | ||
|
|
||
| for students in school: | ||
|
Contributor
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. Тут не students, тут класс типа. |
||
| male_gender = 0 | ||
| female_gender = 0 | ||
|
|
@@ -135,6 +139,15 @@ def max_name(students): | |
| male_gender += 1 | ||
| else: | ||
| female_gender += 1 | ||
| boys_predominate = 'Больше всего мальчиков в классе ' | ||
| girls_predominate = 'Больше всего девочек в классе ' | ||
| print(f'{boys_predominate}{students["class"]}') if male_gender > female_gender else print(f'{girls_predominate}{students["class"]}') | ||
| if male_gender > female_gender: | ||
|
Contributor
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. Кажется, у этого ифа лишний отступ |
||
| max_male_gender = male_gender | ||
| max_male_class = str(students["class"]) | ||
|
Contributor
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. students["class"] и так строка, не надо её ещё раз превращать в строку. |
||
| if male_gender > max_male_gender: | ||
| max_male_gende = male_gender | ||
| else: | ||
| max_female_gender = female_gender | ||
| max_female_class = str(students["class"]) | ||
| if female_gender > max_female_gender: | ||
| max_female_gender = female_gender | ||
| print(f'Больше всего мальчиков в классе {max_male_class}') | ||
| print(f'Больше всего девочек в классе {max_female_class}') | ||
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.
Теперь K из принта надо убрать, а то получается, что там теперь 100000к. Аналогично принтами ниже.