Розмір відео: 1280 X 720853 X 480640 X 360
Показувати елементи керування програвачем
Автоматичне відтворення
Автоповтор
# POOP = Python object-oriented programming# Each object can have its own set of methods and attributesfrom car import Carcar1 = Car("Chevy", "Corvette", 2019, "Black")car2 = Car("Chevy", "Camaro", 2014, "Red")car3 = Car("Wooden", "sofa", 2020, "purple")print(car3.make)print(car3.model)print(car3.year)print(car3.color)car3.drift()car3.drive()car2.wheels = 2print(car3.wheels)class Car: wheels = 4 # class variable def __init__(self, make, model, year, color): self.make = make # instance variables self.model = model # instance variables self.year = year # instance variables self.color = color # instance variables def drift(self): print("This "+self.model+" is drifting :D") def drive(self): print("This "+self.model+" is driving :D")class motorcycle: pass
# POOP = Python object-oriented programming
# Each object can have its own set of methods and attributes
from car import Car
car1 = Car("Chevy", "Corvette", 2019, "Black")
car2 = Car("Chevy", "Camaro", 2014, "Red")
car3 = Car("Wooden", "sofa", 2020, "purple")
print(car3.make)
print(car3.model)
print(car3.year)
print(car3.color)
car3.drift()
car3.drive()
car2.wheels = 2
print(car3.wheels)
class Car:
wheels = 4 # class variable
def __init__(self, make, model, year, color):
self.make = make # instance variables
self.model = model # instance variables
self.year = year # instance variables
self.color = color # instance variables
def drift(self):
print("This "+self.model+" is drifting :D")
def drive(self):
print("This "+self.model+" is driving :D")
class motorcycle:
pass