Write a class named Car that has the following data attributes in pyton: a. __year_model (for the car’s year model) __make (for the make of the car) __speed (for the car’s current speed) The Car class should have an __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. The class should also have the following methods: b. Accelerate: The accelerate method should add 5 to the speed data attribute each time it is called. Brake: The brake method should subtract 5 from the speed data attribute each time it is called. get_speed: The get_speed method should return the current speed
Write a class named Car that has the following data attributes in pyton:
a. __year_model (for the car’s year model)
__make (for the make of the car)
__speed (for the car’s current speed)
The Car class should have an __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.
The class should also have the following methods:
b. Accelerate: The accelerate method should add 5 to the speed data attribute
each time it is called.
Brake: The brake method should subtract 5 from the speed data attribute each
time it is called.
get_speed: The get_speed method should return the current speed
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images