From d2b8cefbb0765c3d9974ecae17b23079ad6e4ad5 Mon Sep 17 00:00:00 2001 From: Cerys Date: Tue, 3 Nov 2020 10:19:50 +0000 Subject: [PATCH 1/2] adding my group to my branch --- group.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/group.py b/group.py index e2ec347..5aaec0f 100644 --- a/group.py +++ b/group.py @@ -2,4 +2,27 @@ # Your code to go here... -my_group = +my_group={ + 'Jill' : {'age' : '26' , 'job' : 'a Biologist' , + 'connection' : { + 'Zalika':'friend', + "John" : 'partner' + } + }, + 'Zalika' : {'age' : '28' , 'job' : 'an Artist' , + 'connection' : { + 'Jill' : 'friend' + } + }, + 'John' : {'age' : '27' , 'job' : 'a Writer' , + 'connection' : { + 'Jill' : 'partner' + } + }, + 'Nash' : {'age' : '34' , 'job' : 'a Chef' , + 'connection' : { + 'John' : 'cousin', + 'Zalika' : 'landlord' + } + } + } From d01fc39fe9961c7eafb994533b8788ec6670b3e4 Mon Sep 17 00:00:00 2001 From: Cerys Date: Tue, 3 Nov 2020 13:04:31 +0000 Subject: [PATCH 2/2] Adding the code to print stats about the group. --- group.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/group.py b/group.py index 5aaec0f..7e8691d 100644 --- a/group.py +++ b/group.py @@ -2,7 +2,7 @@ # Your code to go here... -my_group={ +friends={ 'Jill' : {'age' : '26' , 'job' : 'a Biologist' , 'connection' : { 'Zalika':'friend', @@ -26,3 +26,14 @@ } } } + +maxage = max([deets['age'] for person , deets in friends.items()]) +avgconnection = sum([len(deets['connection']) for person, deets in friends.items()])//4 +oldestif1=max([deets['age'] for person, deets in friends.items() if len(deets['connection']) > 0 ]) +oldestif1friend = max( [deets['age'] for person, deets in friends.items() if 'friend' in friends[person]['connection'].values() ]) + + +print('The age of the oldest person in the group is ', maxage, ' years old.') +print('Each person has' , avgconnection, 'relation on average.') +print('The maximum age of the person in the group that has at least one relation is', oldestif1, 'years old.') +print('The maximum age of the person in the group that has at least one friend is', oldestif1friend, 'years old.') \ No newline at end of file