From efd366429b3e94c981d935a420dde705b5701109 Mon Sep 17 00:00:00 2001 From: Harry Booth <39346323+harrybooth@users.noreply.github.com> Date: Tue, 27 Oct 2020 17:32:24 +0000 Subject: [PATCH] added statistics readout --- group.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/group.py b/group.py index e2ec347..5e15776 100644 --- a/group.py +++ b/group.py @@ -3,3 +3,49 @@ # Your code to go here... my_group = +"""An example of how to represent a group of acquaintances in Python.""" + +# Your code to go here... + +my_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" + } + } +} + +print("max age:" + str(max([value['age'] for value in my_group.values()]))) + +a = [len(value['relations']) for value in my_group.values()] + +print("Average no of relations: " + str(sum(a)/len(a))) + +b = [value['age'] for value in my_group.values() if len(value['relations']) >= 1] + +print("Max age of people with >= 1 relation: " + str(max(b))) \ No newline at end of file