classes — reading what ai just wrote you8 / 9
class, __init__, self — the three keywords ai uses every time
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.
Booting Python…
Output
[promptdojo:~]$ _