Files
freeCodeCamp/curriculum/challenges/english/07-scientific-computing-with-python/python-for-everybody/object-lifecycle.md
Oliver Eyton-Williams 0bd52f8bd1 Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
2020-11-27 10:02:05 -08:00

856 B

id, title, challengeType, videoId
id title challengeType videoId
5e7b9f170b6c005b0e76f087 Object Lifecycle 11 p1r3h_AMMIM

--question--

--text--

What will the following program print?:

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