Class:Inheritance

Run Settings
LanguagePython
Language Version
Run Command
# Inheritance # Parent Class class User: def sign_in(self): print('logged in') # Sub Class/ Child Class/ Derived Class class Wizard(User): def __init__(self, name, power): self.name = name self.power = power def attack(self): print(f'Attacking with power of {self.power}') class Archer(User): def __init__(self, name, num_arrows): self.name = name self.num_arrows = num_arrows def attack(self): print(f'Attacking with arrows: Arrows left- {self.num_arrows}') wizard1 = Wizard('Merlin', 50) archer1 = Archer('Robbin', 100) wizard1.attack() archer1.attack() archer1.sign_in() print(isinstance(wizard1, Wizard)) print(isinstance(wizard1, User)) print(isinstance(wizard1, object))
Editor Settings
Theme
Key bindings
Full width
Lines