Create a car class with three attributes: year, mpg, speed and list of owners. The class...

70.2K

Verified Solution

Question

Programming

Create a car class with three attributes: year, mpg, speed andlist of owners. The class also should have 2 methods calledaccelerate and brake. Whenever the car accelerates, its speed isincreased by 30 and whenever the car brakes, its speed is reducedby 60.

  1. add a constructor to the class, which takes year, mpg, andspeed as input
  2. implement a magic method that prints the car informationincluding year, speed and mpg. That is, for a car object,car1=car(2016, 20, 80), print(car) command should printcar_year_2016_mpg_20_speed_80.
  3. create two car objects: car1 and car2. record 'John Doe' and'Jack Jones' as the previous owners of car1 and 'John Flack' and'Jeff Heath' as the previous owners of car2. Verify that the listof car1 owners and list of car2 owners are different.

Use a python programming code

Answer & Explanation Solved by verified expert
3.6 Ratings (485 Votes)
Program CodeScreenshotSampleOutputThe screenshots are attached below for referencePlease follow them for proper indentation and outputProgram    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students