Conversation
| @@ -1,5 +1,21 @@ | |||
| """An example of how to represent a group of acquaintances in Python.""" | |||
| class PersonData: | |||
There was a problem hiding this comment.
That's a really nice way to model out a person!
There was a problem hiding this comment.
Within the print() at the end of the attempt, they are accessing all connections under 'John', but maybe it would also be useful to have a way to access the global connections/network.
| zalika = PersonData('Zalika', 28, 'Artist', {'Friend':['Jill']}) | ||
| john = PersonData('John',27,'Writer',{'Partner':['Jill']}) | ||
| nash = PersonData('Nash',34,'Chef',{'Cousin':['John'],'Landlord':['Zalika']}) | ||
|
|
There was a problem hiding this comment.
It looks more clean and organised, tidy.
There was a problem hiding this comment.
They put all the connections in list.
| self.name = name | ||
| self.age = age | ||
| self.occupation = occupation | ||
| self.connections = connections |
| john = PersonData('John',27,'Writer',{'Partner':['Jill']}) | ||
| nash = PersonData('Nash',34,'Chef',{'Cousin':['John'],'Landlord':['Zalika']}) | ||
|
|
||
| # Your code to go here... |
There was a problem hiding this comment.
I really like the approach of defining each person as a PersonData object and then creating a dictionary of those objects. I feel like you might be overusing the person's name as it is a variable in the class, the name of the object and the key in the dictionary. It might be worth changing one of these into a unique identifier in case there were two or more people with the same name in the data.
| self.name = name | ||
| self.age = age | ||
| self.occupation = occupation | ||
| self.connections = connections |
There was a problem hiding this comment.
Our group discussed the interesting use of class
| friendGroup = { | ||
| 'Jill': jill, | ||
| 'Zalika': zalika, | ||
| 'John': john, |
There was a problem hiding this comment.
This use of dictionary seemed appropriate and helped us better understand dictionaries
erg43
left a comment
There was a problem hiding this comment.
This looks clever. It seems efficient to access
Trying to practice by attempting homework UCL-MPHY0021-21-22#12 group.py
@zengxueyuan (Not sure of other members ID's)
Answers UCL-MPHY0021-21-22/RSE-Classwork#7