51 Defining New Classes | Python [ COMPLETE COURSE ]

Опубликовано: 21 Август 2020
на канале: Tech Lab
40
0

We can create and define our classes in Python similar to how we define functions. We start with the class keyword, followed by the name of our class and a colon. Python style guidelines recommend class names to start with a capital letter. After the class definition line is the class body, indented to the right. Inside the class body, we can define attributes for the class.
We can create a new instance of our new class by assigning it to a variable. This is done by calling the class name as if it were a function. We can set the attributes of our class instance by accessing them using dot notation. Dot notation can be used to set or retrieve object attributes, as well as call methods associated with the class
We created an Apple instance called jonagold, and set the color and flavor attributes for this Apple object. We can create another instance of an Apple and set different attributes to differentiate between two different varieties of apples.
We now have another Apple object called golden that also has color and flavor attributes. But these attributes have different values.


Christine Rafla
Email us at - techlaboffice77@gmail.com


На этой странице сайта вы можете посмотреть видео онлайн 51 Defining New Classes | Python [ COMPLETE COURSE ] длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Tech Lab 21 Август 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 40 раз и оно понравилось 0 зрителям. Приятного просмотра!