diff --git a/group.py b/group.py index e2ec347..059737b 100644 --- a/group.py +++ b/group.py @@ -2,4 +2,47 @@ # Your code to go here... -my_group = +group = { + "Jill": { + "age": 26, + "job": "biologist", + "relations": { + "Zalika": "friend", + "John": "partner" + } + }, + "Zalika": { + "age": 28, + "job": "artist", + "relations": { + "Jill": "friend" + } + }, + "John": { + "age": 27, + "job": "writer", + "relations": { + "Jill": "partner" + } + }, + "Nash": { + "age": 34, + "job": "chef", + "relations": { + "John": "cousin", + "Zalika": "landlord" + } + } +} + +import numpy as np + +max_age = max([group[person]["age"] for person in group]) +mean_relations = np.average([len(group[person]["relations"]) for person in group]) +max_age_min_one_relation = max([group[person]["age"] for person in group if len(group[person]["relations"]) >= 1]) +max_age_min_one_friend = max([group[person]["age"] for person in group if "friend" in list(group[person]["relations"].values())]) + +print("The maximum age of people in the group is " + str(max_age)) +print("The mean number of relations is " + str(mean_relations)) +print("The maximum age of people with at least one relation is " + str(max_age_min_one_relation)) +print("The maximum age of people with at least one friend is " + str(max_age_min_one_friend)) \ No newline at end of file