Design a class that holds the following personal data name


Assignment

Problem 1: Car Class

1. Write a class named Car that has the following data attributes:

o __year_model (for the car's year model)

o __make (for the make of the car)

o __speed (for the car's current speed)

o 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:

o accelerate

The accelerate method should add 5 to the speed data attribute each time it is called.

o brake

The brake method should subtract 5 from the speed data attribute each time it is called.

o get_speed

The get_speed method should return the current speed.

o Next, design a program that creates a Car object and then calls the accelerate method five times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brakemethod five times. After each call to the brake method, get the current speed of the car and display it.

Problem 2: Personal InformationClass

1. Design a class that holds the following personal data: name, address, age, and phone number. Write appropriate accessor and mutator methods. Also, write a program that creates three instances of the class. One instance should hold your information, and the other two should hold your friends' or family members' information.

Solution Preview :

Prepared by a verified Expert
Python Programming: Design a class that holds the following personal data name
Reference No:- TGS02513025

Now Priced at $50 (50% Discount)

Recommended (93%)

Rated (4.5/5)