Question: Write the Python code that defines a class called Vehicle , which will have a maximum occupancy of 8 . The vehicle should be initialized
Write the Python code that defines a class called Vehicle, which will have a maximum occupancy of 8. The vehicle should be initialized with the number of occupants. If the number of occupants exceeds the limit during initialization, it should print a message indicating that the limit has been exceeded and only initialize how many occupants should step off the vehicle. The first vehicle has 6 occupants and the second vehicle has 10 occupants.
Output:
The first vehicle has 6 occupants.
The maximum occupancy limit has been exceeded. 2 occupants must exit the vehicle.
The second vehicle has 10 occupants.
Step by Step Solution
3.42 Rating (146 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
