セクション 1. 章 3
single
Implementation
メニューを表示するにはスワイプしてください
Code
We start to fill the Cat class:
- An attribute
namewith the predefined value'Kitty'; - A method
say_meow().
We create an object cat and call the say_meow() method.
12345678910class Cat: # An attribute name = 'Kitty' # A method def say_meow(self): print('Meow') # Instantiating an object cat = Cat() cat.say_meow()
Note
- Each method obligatory contains
self- a reference to the current object; - To call the method of the object, write
Object.Method().
タスク
スワイプしてコーディングを開始
- Add the
sleepmethod. - The
sleepmethod prints a message. - Instantiate an object using the
catvariable.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 3
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください