* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
74 lines
885 B
Markdown
74 lines
885 B
Markdown
---
|
|
id: 5e7b9f170b6c005b0e76f087
|
|
title: Object Lifecycle
|
|
challengeType: 11
|
|
videoId: p1r3h_AMMIM
|
|
dashedName: object-lifecycle
|
|
---
|
|
|
|
# --question--
|
|
|
|
## --text--
|
|
|
|
What will the following program print?:
|
|
|
|
```python
|
|
class PartyAnimal:
|
|
x = 0
|
|
name = ''
|
|
def __init__(self, nam):
|
|
self.name = nam
|
|
print(self.name,'constructed')
|
|
def party(self):
|
|
self.x = self.x + 1
|
|
print(self.name,'party count',self.x)
|
|
|
|
q = PartyAnimal('Quincy')
|
|
m = PartyAnimal('Miya')
|
|
|
|
q.party()
|
|
m.party()
|
|
q.party()
|
|
```
|
|
|
|
## --answers--
|
|
|
|
Quincy constructed
|
|
|
|
Miya constructed
|
|
|
|
Quincy party count 1
|
|
|
|
Miya party count 2
|
|
|
|
Quincy party count 3
|
|
|
|
---
|
|
|
|
Quincy constructed
|
|
|
|
Miya constructed
|
|
|
|
Quincy party count 1
|
|
|
|
Miya party count 1
|
|
|
|
Quincy party count 2
|
|
|
|
---
|
|
|
|
Quincy constructed
|
|
|
|
Quincy party count 1
|
|
|
|
Quincy party count 2
|
|
|
|
Miya constructed
|
|
|
|
Miya party count 1
|
|
|
|
## --video-solution--
|
|
|
|
2
|
|
|