Write a class named Car that has the following data attributes: __year_model: (for the car's year model) __make: (for the make of the car) __speed: (for the car's current speed) In addition, the class should have the following methods: __init__ method that accepts the car’s year model and make as arguments. These values should be assigned to the object’s __year_model and __make data attributes. It should also assign 0 to the __speed data attribute. accelerate: The accelerate method should add 5 to the speed data attribute when it is called. brake: The brake method should subtract 5 from the speed data attribute eachtime it is called. get_speed: The get_speed method should return the current speed

Respuesta :

Answer: Provided in the explanation section

Explanation:

Provided below is the program to carry out this task, i hope you can follow it clearly.

Program is run below

class Car:

   def __init__(self, model, make):

       self.__year_model = model

       self.__make = make

       self.__speed = 0

   def accelerate(self):

       self.__speed += 5

   def brake(self):

       self.__speed -= 5

   def get_speed(self):

       return self.__speed

car = Car("F1", "Ferrari")

for i in range(5):

   car.accelerate()

   print(car.get_speed())

for i in range(5):

   car.brake()

   print(car.get_speed())

cheers i hope this helped !!