The class's default goal and one person's goal

Predict the output · Medium · §11.4 Shared by all, owned by each

The default value of the follower goal goal is a class variable. Predict the output without running the code.

Code

class Creator:
    goal = 100

    def __init__(self, name):
        self.name = name
        self.followers = 0

    def gain(self, n):
        self.followers += n

    def set_goal(self, n):
        self.goal = n

    def __str__(self):
        return f"{self.name} {self.followers}/{self.goal}"

a = Creator("mina")
b = Creator("jun")
a.gain(80)
b.set_goal(50)
Creator.goal = 120
print(a)
print(b)
print(Creator.goal)

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.