class Dog:
passLine-by-line explanation
classbegins a class definition.Dogis the class name.- The colon begins its indented body.
passis a do-nothing placeholder.
pet = Dog()Line-by-line explanation
Dog()creates one instance.petstores that object.
Tiny Practice
Create one object from the empty Book class.
Starter template
class Book:
pass
my_book = CHANGE_MELine-by-line explanation
- The class is already defined.
- The missing expression creates an instance.
Hint
- Use the class name.
- Add round brackets.
- Do not use quotes.
Show Solution
class Book:
pass
my_book = Book()Line-by-line explanation
- The class defines a blueprint.
Book()creates an instance.my_bookstores it.