Learn Python Object Oriented Programming! π
#python #pythonprogramming #pythontutorial 00:00:00 introduction 00:01:53 classes 00:02:19 constructors 00:04:13 instantiate objects 00:05:06 attribute acc...

Bro Code
84.8K views β’ May 20, 2024

About this video
#python #pythonprogramming #pythontutorial
00:00:00 introduction
00:01:53 classes
00:02:19 constructors
00:04:13 instantiate objects
00:05:06 attribute access operator
00:06:09 multiple objects
00:07:19 modules
00:08:21 methods
00:11:52 conclusion
# object = A "bundle" of related attributes (variables) and methods (functions)
# Ex. phone, cup, book
# You need a "class" to create many objects
# class = (blueprint) used to design the structure and layout of an object
# --------------- car.py ---------------
class Car:
def __init__(self, model, year, color, for_sale):
self.model = model
self.year = year
self.color = color
self.for_sale = for_sale
def drive(self):
# print("You drive the car")
# print(f"You drive the {self.model}")
print(f"You drive the {self.color} {self.model}")
def stop(self):
# print("You stop the car")
# print(f"You stop the {self.model}")
print(f"You stop the {self.color} {self.model}")
def describe(self):
print(f"{self.year} {self.color} {self.model}")
# --------------------------------------
# --------------- main.py ---------------
from car import Car
car1 = Car("Mustang", 2024, "red", False)
car2 = Car("Corvette", 2025, "blue", True)
car3 = Car("Charger", 2026, "yellow", True)
print(car1.model)
print(car1.year)
print(car1.color)
print(car1.for_sale)
car1.drive()
car1.stop()
car3.describe()
# --------------------------------------
00:00:00 introduction
00:01:53 classes
00:02:19 constructors
00:04:13 instantiate objects
00:05:06 attribute access operator
00:06:09 multiple objects
00:07:19 modules
00:08:21 methods
00:11:52 conclusion
# object = A "bundle" of related attributes (variables) and methods (functions)
# Ex. phone, cup, book
# You need a "class" to create many objects
# class = (blueprint) used to design the structure and layout of an object
# --------------- car.py ---------------
class Car:
def __init__(self, model, year, color, for_sale):
self.model = model
self.year = year
self.color = color
self.for_sale = for_sale
def drive(self):
# print("You drive the car")
# print(f"You drive the {self.model}")
print(f"You drive the {self.color} {self.model}")
def stop(self):
# print("You stop the car")
# print(f"You stop the {self.model}")
print(f"You stop the {self.color} {self.model}")
def describe(self):
print(f"{self.year} {self.color} {self.model}")
# --------------------------------------
# --------------- main.py ---------------
from car import Car
car1 = Car("Mustang", 2024, "red", False)
car2 = Car("Corvette", 2025, "blue", True)
car3 = Car("Charger", 2026, "yellow", True)
print(car1.model)
print(car1.year)
print(car1.color)
print(car1.for_sale)
car1.drive()
car1.stop()
car3.describe()
# --------------------------------------
Tags and Topics
Browse our collection to discover more content in these categories.
Video Information
Views
84.8K
Likes
2.5K
Duration
12:18
Published
May 20, 2024
User Reviews
4.7
(16) Related Trending Topics
LIVE TRENDSRelated trending topics. Click any trend to explore more videos.