Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

The function #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
82 changes: 81 additions & 1 deletion group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,84 @@

# 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"
}
}
}

# print(group['Jill']['age'])

def findMaximunAge():
name = 'Jill'
temp = group['Jill']['age']
for people in group:
if group[people]['age'] > temp:
name = people
temp = group[people]['age']
return name

def mean_realationship():
temp = 0
PeopleNo = 0
for people in group:
PeopleNo = PeopleNo + 1
temp = len(group[people]['relations'])+temp
return temp/PeopleNo

def MaxAgeOnerelationship():
name = 'Jill'
temp = group['Jill']['age']
for people in group:
if group[people]['age'] > temp and len(group[people]['relations']) >=1:
name = people
temp = group[people]['age']
return name

def MaxAgeOneFriend():
name = 'Jill'
temp = group['Jill']['age']
for people in group:
if group[people]['age'] > temp and len(group[people]['relations']) >=1:
for index in group[people]['relations']:
if group[people]['relations'][index] == 'friend':
name = people
temp = group[people]['age']
return name


print(findMaximunAge())
print(mean_realationship())
print(MaxAgeOnerelationship())
print(MaxAgeOneFriend())