W3Schools Tryit Editor
[
フレーム
]
Run ❯
Get your
own Python
server
Go to Spaces
Ctrl+Alt+P
class Car: def __init__(self, brand, model): self.brand = brand self.model = model self.engine = self.Engine() class Engine: def __init__(self): self.status = "Off" def start(self): self.status = "Running" print("Engine started") def stop(self): self.status = "Off" print("Engine stopped") def drive(self): if self.engine.status == "Running": print(f"Driving the {self.brand} {self.model}") else: print("Start the engine first!") car = Car("Toyota", "Corolla") car.drive() car.engine.start() car.drive()
Start the engine first!
Engine started
Driving the Toyota Corolla
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル