Skip to content
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

PR Friend Group Conditional Age Calculations #31

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

Conversation

TimWeaving
Copy link

Outputs the following:

Maximum overall age is 34
Average overall age is 28.750000
Maximum age of those with at least one relative is 34
Maximum age of those with at least one friend is 28

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

Comment on lines +34 to +42
ages = [my_group[key]['age'] for key in my_group.keys()]
ages_rel = [my_group[key]['age'] for key in my_group.keys() if my_group[key]['relations']] #includes age if relations not empty (however in this case all entries have at least one relation)
ages_frnd = [my_group[key]['age'] for key in my_group.keys() if 'friend' in my_group[key]['relations'].values()]


print("Maximum overall age is %i" % max(ages))
print("Average overall age is %f" % (sum(ages)/len(ages)))
print("Maximum age of those with at least one relative is %i" % max(ages_rel))
print("Maximum age of those with at least one friend is %i" % max(ages_frnd))
Copy link
Collaborator

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