Design a Python3 'Race Car' class, where that vehicle has the following attributes: type (sports, street, muscle, super,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Design a Python3 'Race Car' class, where that vehicle has the following attributes: type (sports, street, muscle, super,

Post by answerhappygod »

Design a Python3 'Race Car' class, where that vehicle has the
following attributes: type (sports, street, muscle, super, hyper),
acceleration value (float value between 1000.0- 10000.0), top speed
(float value between 1000.0-10000.0), and nitro (float value
between 1000.0-10000.0), color (a string value), year, number of
doors (integer between 2-4), speed (initially 0). And the following
methods are; accelerate (accelerates the car speed by 10 in each
call but not more than the top speed), brake (decreases the speed
by 10 in each call but now lower than 0) turn left, turn right,
reverse. For the last 3 methods you can give output such as
'Turning left..','' Turning right...' etc
Please be sure to raise exceptions for things such as the
'accelerate' and 'brake' methods (to avoid going above top speed
when accelerating and below 0 when hitting the brake).

Thank you
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply