class, __init__, self — the three keywords AI uses every time — step 8 of 9
Write a class called Score that:
- Takes no arguments to its
__init__(besidesself). - Sets
self.pointsto0in__init__. - Has a method
add(self, n)that increasesself.pointsbyn.
Then create one instance, call .add(3) and .add(7), and print
the final points.
Expected output:
10
⌘↵ runs the editor.read, then continue.
Write a class called Score that:
- Takes no arguments to its
__init__(besidesself). - Sets
self.pointsto0in__init__. - Has a method
add(self, n)that increasesself.pointsbyn.
Then create one instance, call .add(3) and .add(7), and print
the final points.
Expected output:
10
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.