From the course: Programming Foundations: Real-World Examples
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Custom objects - Python Tutorial
From the course: Programming Foundations: Real-World Examples
Custom objects
- Out of the box, object-oriented programming languages give us the ability to create objects for common types of things like representing numbers and strings. But if I want to create my own custom types of objects, I can do so by defining classes which are the blueprints used to create new objects. A class defines the attributes and methods that make up a specific type of object. This class for a pair of blue jeans would describe its attributes for waist size, length, and color as well as methods for donning and removing the jeans. This blueprint might also have a special constructor method for creating a new pair of jeans object which allows me to specify values for size, length and color when I create a new jeans object. If I wanted to construct a new pair of jeans, I could do so by following these blueprints to give the new jean object the appropriate attributes. But I'm not that good at sewing. As a modern man, I buy my pants on the internet. This online order page is like the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.