Python Encapsulation - Python programming for beginners.
The video explains what encapsulation is and how to use it.
Music by Bensound, www.bensound.com
class Vehicle():
def __init__(self, name, speed):
self._name = name
self.set_name(name)
self._speed = speed
self.set_speed(speed)
def acceleration(self):
self.speed += 5
def brake(self):
self.speed -= 5
def get_name(self):
return self._name
def set_name(self, value):
self._name = value.upper()
def get_speed(self):
return self._speed
def set_speed(self, value):
self._speed = value
car = Vehicle("Red car", 100)
print(car.get_name())
print(car.get_speed())
On this page of the site you can watch the video online Python Getter and Setter methods, Encapsulation basics - Python programming for beginners with a duration of hours minute second in good quality, which was uploaded by the user Brendan Callaghan 27 January 2023, share the link with friends and acquaintances, this video has already been watched 211 times on youtube and it was liked by 4 viewers. Enjoy your viewing!