Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
"""An example of how to represent a group of acquaintances in Python."""

import numpy as np

# Your code to go here...
'''
class Person:
def __init__(self,name,age,job,relationship):
self.name = name
self.age = age
self.job = job
self.relationship = relationship

Jill = Person('Jill','26','biologist',[['friend','Zalika'],['partner','John']])
Zalika = Person('Zalika','28','artist',[['friend','Jill']])
John = Person('John','writer',[['partner','Jill']])
Nash = Person('Nash','34','chef',[['cousin','John'],['tenant','Zalika']])

print(Jill.name)
print(Jill.relationship)
print(Jill.job)
'''

my_group = {
'Jill':{'age':26,'job':'biologist','relationship':{'friend':'Zalika','partner':'John'}},
'Zalika':{'age':28,'job':'artist','relationship':{'friend':'Jill'}},
'John':{'age': 27,'job':'writer','relationship':{'partner':'Jill'}},
'Nash':{'age':34,'job':'chef','relationship':{'cousin':'John','tenant':'Zalika'}}
}

#print(my_group)

#maxage = max(my_group, key=lambda dic:dic['age'])
#print(maxage['age'])

numrel = 0
maxage = 0
i = 0


for name, person in my_group.items():
#print("name: ", name, ", age:", person['age'], ", relation: ")
#print(len(person['relationship']))
numrel = numrel + len(person['relationship'])
i = i + 1
if person['age']>maxage:
maxage = person['age']
maxname = name
if len(person['relationship'])>1:
relname = name
for rel in person['relationship']:
if rel == 'friend':
friname = name


print("max age: ", maxage)
print("avg relations: ", numrel/i)

my_group =
print("the maximum age of people in the group that have at least one relation: ", relname)
print("the maximum age of people in the group that have at least one friend: ", friname)