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

Exercises with group.py #47

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

Exercises with group.py #47

wants to merge 2 commits into from

Conversation

FMAUR92
Copy link

@FMAUR92 FMAUR92 commented Oct 23, 2020

@FMAUR92
Copy link
Author

FMAUR92 commented Oct 24, 2020

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

@FMAUR92 FMAUR92 changed the title Added comprehensions to group.py Exercises with group.py Oct 24, 2020
Comment on lines +39 to +47
max_age = max(person['age'] for name, person in group.items())
print(max_age)
avg_rels = statistics.mean(len(person['relations']) for name, person in group.items())
print(avg_rels)
max_age_1_rel = max(person['age'] for name, person in group.items() if len(person['relations']) > 0)
print(max_age_1_rel)
max_age_1_friend = max(person['age'] for name, person in group.items() if 'friend' in person['relations'].values())
print(max_age_1_friend)

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 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