Skip to content

Adding function for gathering information about age and number of relations #55

Open
cansuoktem wants to merge 2 commits intoUCL-COMP0233-24-25:mainfrom
VictorBay24:cansu
Open

Adding function for gathering information about age and number of relations #55
cansuoktem wants to merge 2 commits intoUCL-COMP0233-24-25:mainfrom
VictorBay24:cansu

Conversation

@cansuoktem
Copy link

Defined a function titled age_relation_info which prints out:
-the maximum age of people in the group
-the average number of relations among members of the group
-the maximum age of people in the group that have at least one relation
-the maximum age of people in the group that have at least one friend

Answers UCL-COMP0233-24-25/RSE-Classwork#7

Copy link

@gpwhs gpwhs left a comment

Choose a reason for hiding this comment

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

generally okay but you don't need to loop through group multiple times, you can get all of the info you need from one loop

also add error handling (e.g. group might not exist)

# Your code to go here...

my_group =
my_group = {"Jill":
Copy link

Choose a reason for hiding this comment

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

did you run the formatter here? (ruff)

f"Max Age: {max(age_vec)}; Average Relations: {sum(relation_vec)/len(group)}; Max Age with >=1 Relation: {max(age_relat_vec)}; Max Age with >=1 Friend: {max(age_friend_vec)}"
)

age_relation_info()
Copy link

Choose a reason for hiding this comment

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

this will run every time you import group.py

wrap in a if name == "main" condition :-)

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