Python Constructors and Methods, object-oriented programming - Python programming for beginners. In this video I teach the basics of object-oriented programming and how to get started in building your first class.
Code for tutorial: -
---------------------------------------------------------------------------
class Car:
def __init__(self,name,speed):
self.name = name
self.speed = speed
def acceleration(self):
self.speed += 5
def brake(self):
self.speed -= 5
def display_car(self):
print(f"The cars name is {self.name}")
print(f"The cars speed is {self.speed}")
from car import Car
car1 = Car()
# print(car1)
# car1.name = "blue"
car1.speed = 100
# print(car1.speed)
print(car1.name)
car2 = Car("red", 200)
print(car2.speed)
print(car2.name)
car2.acceleration()
car2.acceleration()
print(car2.speed)
car2.brake()
print(car2.speed)
car2.display_car()
En esta página del sitio puede ver el video en línea Python Constructors and Methods, object-oriented programming - Python programming for beginners. de Duración hora minuto segunda en buena calidad , que subió el usuario Brendan Callaghan 17 noviembre 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 120 veces y le gustó 3 a los espectadores. Disfruta viendo!