Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Hw3 json r/w #48

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

Hw3 json r/w #48

wants to merge 5 commits into from

Conversation

Chiiizzzy
Copy link

@Chiiizzzy
Copy link
Author

Answers UCL-RITS/rse-classwork-2020#11

@Chiiizzzy Chiiizzzy changed the title add code to analyse ages Hw3 json r/w Oct 28, 2020
Comment on lines +39 to +42
ages = [my_group[key]['age'] for key in my_group.keys()]
relations = [my_group[key]['relations'] for key in my_group.keys()]
ages_with_r = [my_group[key]['age'] for key in my_group.keys() if my_group[key]['relations']]
ages_with_f = [my_group[key]['age'] for key in my_group.keys() if 'friend' in my_group[key]['relations'].values() ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines +44 to +47
print('the maximum age of people in the group: %d' %max(ages));
print('the average (mean) number of relations among members of the group: %.2f' %(sum(ages)/len(ages)))
print('the maximum age of people in the group that have at least one relation: %d' %max(ages_with_r))
print('the maximum age of people in the group that have at least one friend: %d' %max(ages_with_f))
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe using a f string or a string.format() here would be more clear and modern python

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants