Quick actions

cmd+k|ctrl+k

Navigation

Languages

class barbie

Snippet info

Language

Python

Visibility

public

Author

catfisherinvisible

Created

2026-07-10T06:47:41.214475Z

Updated

2026-07-10T09:59:28.418656Z

class Toy:                #Static # variable and function belongs to Toy class only # variable tocarry to object
    head = "circle"
    hands = 2
    legs = 1
    # function won't carry to object
    def a():
        print("class only function")
    def __init__(self,x,y,name):
        self.name = name
        self.body = x
        self.hat = y
    def run(self):
        print(f"{self.name} is running")
class Barbie(Toy):            #Dynamic # Have shell
    def __init__(self,x,y,name,hair):
        super().__init__(x,y,name)
        self.hair = hair
        print(f"Barbie: hair {self.hair}")
    def jump(self):
        print(f"Barbie: {self.name} jump")
        # overwrite parent's function with additional function
    def run(self):
        super().run()
        print(f"{self.name} don't like running")
barbie_baby = Barbie('short','white','bb','black')
barbie = Barbie('tall','green','bb-girl','red')
print(barbie_baby.name)
print(barbie.body)
barbie_baby.run()
barbie_baby.jump()
print(barbie.head)
Toy.a()
INFO