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

Complete Issue #10 work and improved data structure #52

Closed
wants to merge 3 commits into from
Closed

Complete Issue #10 work and improved data structure #52

wants to merge 3 commits into from

Conversation

AlexWilkinsonnn
Copy link

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

What?

Completed the work for Data structures and comprehension expressions Issue.

Why?

To learn!

How?

Improved data structed to make use of a class then used list comprehensions to complete tasks.

Comment on lines +67 to +82
max_age = max([ person.age for person in my_group ])
print('Maximum age = ' + str(max_age))

# Average number of relations
mean_rels = np.mean([ len(person.relations.keys()) for person in my_group ])
print('Mean number of relations = ' + str(mean_rels))

# Maximum age for ppl with at least one relation
max_age_min1rel = max([ person.age for person in my_group if len(person.relations.keys()) >= 1 ])
print('Maximum age of people with at least one relation = ' + str(max_age_min1rel))

# Maximum age for ppl with at least one friend
max_age_min1friend = max([ person.age for person in my_group if 'friend' in person.relations.values() ])
print('Maximim age of people with at least one friend = ' + str(max_age_min1friend))

my_group_dict = { person.name : {'age' : person.age, 'job': person.job, 'relations' : person.relations_str()} for person in my_group }
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