Let's quickly demonstrate classes and objects by creating a pizza class. Our goal is to have instances of the pizza class provide us with a description and price, as required by the current business needs. If you took our fundamentals of programming course, this will be similar to the examples we covered, but this time we'll use object-oriented programming. To start, we'll create a pizza class in Python, and instead of typing out the code, I'll show it to you. The class has an initializer method with the special name init. In Python, the first parameter to a method is a reference to the instance itself, conventionally named self. The second parameter is the diameter of the pizza, and we currently have a placeholder keyword "Pass" in place of the actual code, which we'll add later. We create a new instance of the pizza class with a diameter of 16, and this will become the second parameter for the initializer method. When using an initializer in Python, we don't provide a reference to the instance, as it's automatically added for us. We want to print the description and price of the pizza instance, but we haven't added the necessary code yet, so attempting to run it will result in an error. We'll cover how to add the necessary attributes and methods in the encapsulation lesson. For now, we've created a pizza class in Python and a single pizza instance. That concludes this brief demonstration.
https://freezlike.co/?id=dawoodjan2000