-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add code that extracts information from the data structure #46
Open
nikoSchoinas
wants to merge
4
commits into
UCL-RITS:main
Choose a base branch
from
twemyss:nikoSchoinas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nikoSchoinas
changed the title
Add code that extracts information from the data stracture
Add code that extracts information from the data structure
Oct 23, 2020
stefpiatek
reviewed
Oct 29, 2020
Comment on lines
+52
to
+66
group_ages = [value['age'] for value in my_group.values()] | ||
print("the maximum age of people in the group is:", max(group_ages)) | ||
|
||
# Block of code that calculates the average of connections | ||
# Follow quite similar approach as before with the difference that now we need the average | ||
group_connections = [len(value['relations']) for value in my_group.values()] | ||
print("Every person in the group has an average of", sum(group_connections)/len(group_connections),"relations") | ||
|
||
# Block of code that extracts the maximum age in the group | ||
group_ages = [value['age'] for value in my_group.values() if len(value['relations']) > 0] | ||
print("the maximum age of people in the group that have at least one relation is :", max(group_ages)) | ||
|
||
my_group = | ||
# Block of code that extracts the maximum age of people in the group that have at least one friend | ||
group_ages = [value['age'] for value in my_group.values() for relation_value in value['relations'] if relation_value['type'] == Relation.FRIEND] | ||
print("the maximum age of people in the group that have at least one relation is :", max(group_ages)) |
There was a problem hiding this comment.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Answers UCL-RITS/rse-classwork-2020#10
More specifically the information is: