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

Added code to save group data as a Yaml file #50

Closed
wants to merge 7 commits into from
Closed

Added code to save group data as a Yaml file #50

wants to merge 7 commits into from

Conversation

kumailkermalli16
Copy link

@kumailkermalli16 kumailkermalli16 commented Oct 25, 2020

The group.py has now been updated to save the group dictionary as a Yaml file.

The Yaml file is easier to read (visually), but it causes the entries to be sorted into alphabetical order when reimported. This is not the case for JSON (i think?)

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

Comment on lines +39 to +53
print("The maximum age of the people in the group is:", max({name['age']for group, name in group.items()}))

# average (mean) number of relations among members of the group
relations_person = {len(name['relations']) for group, name in group.items()}
mean = sum(relations_person)/len(relations_person)
print("The average (mean) number of relations among members of the group:", mean)

# the maximum age of people in the group that have at least one relation
print("The maximum age of people in the group that have at least one relation is",
max({name['age'] for group, name in group.items() if len(name['relations']) > 0 }))

# the maximum age of people in the group that have at least one friend (indent for readability)
print ("The maximum age of people in the group that have at least one friend is",
max({name['age'] for group, name in group.items() for relation_name, relation_relation in name['relations'].items()
if 'friend' is (relation_relation)}))
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@kumailkermalli16 kumailkermalli16 closed this by deleting the head repository Feb 18, 2023
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.

3 participants