This tutorial could not be loaded.
Loading tutorial...
Interactive tutorial
Learn how classes define objects and how each object stores state and performs actions. Using short Python examples, you will create instances, initialize attributes, write methods, and distinguish separate objects from shared references. Finish by completing a small class and predicting how its objects behave.
Step 1 of 7
3 min
A Class Defines; an Object Exists
Distinguish a class from its instances and recognize the state and behavior that make up an object.
Step 2 of 7
3 min
Define a Class and Create Instances
Define a minimal Python class and use separate class calls to create two distinct instances.
Step 3 of 7
5 min
Give Each Object Its Own State
Initialize labeled Lamp instances and see how `self` stores separate state on each object.
Step 4 of 7
5 min
Add Behavior with Instance Methods
Define instance methods, call them with dot notation, and trace how they change a Lamp object’s state.
Step 5 of 7
4 min
Separate Objects and Shared References
Learn to distinguish separate Lamp instances from two variables that refer to one shared Lamp object.
Step 6 of 7
3 min
Turn Requirements into a Class Design
Turn a short requirement into a focused class design by separating the entity, its per-instance state, its initial state, and its actions.
Step 7 of 7
7 min
Complete and Trace Your Own Class
Complete a Fan class, trace two independent instances, and verify how object state changes over time.
Video Courses
recommended
Advanced
recommended
Advanced
Advanced
Ideal for beginners
Ideal for beginners
Thousands of online courses in video, ebooks and audiobooks.
To test your knowledge during online courses
Generated directly from your cell phone's photo gallery and sent to your email
Download our app via QR Code or the links below:.
+ 10 million
students
Free and Valid
Certificate
60 thousand free
exercises
4.8/5 rating in
app stores
Free courses in
video and ebooks