This file will contain a class called Car. The Car class takes five input parameters: year, make, model, power, weight. (Do not change these names or order) The class stores the data as attributes, and defines 5 instance methods: power_to_weight_ratio(), __eq__(), __lt__(), and __gt__(), and str() . For the less than, equal to and greater than methods you should only use the power-to-weight ratio. (Doesn't matter what their make/model/year is) Note: Power to weight ratio is the weight divided by the power of the vehicle. A lower number means it will (generally) accelerate faster. Therefore: a car with power to weight ratio of 15 should be "less than" (or slower than) a vehicle with a ratio of 10. The str() method returns "year make model (power hp) Power to Weight Ratio XX lb/hp" where year, make, model, and power are relevant varibles and XX is the power to weight ratio. Use 2 decimal places for the power to weight ratio. vvvvvvvvvvv you code below here vvvvvvvvvvvvvv TEST CODE: if __name__ == '__main__': car1 = Car(2018, "Volkswagen", "Golf GTI", 220, 3062) print("car1 =",car1) car2 = Car(2017, "Subaru", "WRX", 268, 3400) print("car2 =", car2) print("Is car1 faster than car2? ", car1 > car2)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This file will contain a class called Car.

The Car class takes five input parameters: year, make, model, power, weight. (Do not change these names or order)

The class stores the data as attributes, and defines 5 instance methods:
power_to_weight_ratio(), __eq__(), __lt__(), and __gt__(), and str() .

For the less than, equal to and greater than methods you should only use the power-to-weight ratio. (Doesn't matter what their make/model/year is)
Note: Power to weight ratio is the weight divided by the power of the vehicle. A lower number means it will (generally) accelerate faster.
Therefore: a car with power to weight ratio of 15 should be "less than" (or slower than) a vehicle with a ratio of 10.

The str() method returns "year make model (power hp) Power to Weight Ratio XX lb/hp"
where year, make, model, and power are relevant varibles and XX is the power to weight ratio.

Use 2 decimal places for the power to weight ratio.

vvvvvvvvvvv you code below here vvvvvvvvvvvvvv

TEST CODE:
if __name__ == '__main__':
car1 = Car(2018, "Volkswagen", "Golf GTI", 220, 3062)
print("car1 =",car1)
car2 = Car(2017, "Subaru", "WRX", 268, 3400)
print("car2 =", car2)
print("Is car1 faster than car2? ", car1 > car2)

This file will contain a class called Car.
The Car class takes five input parameters: year, make, model, power, weight. (Do not change these names or order)
The class stores the data as attributes, and defines 5 instance methods:
power_to_weight_ratio(), --eq_-), --lt__(), and --gt__(), and str() .
For the less than, equal to and greater than methods you should only use the power-to-weight ratio. (Doesn't matter what their make/model/uear is)
the power of the vehicle. A lower number means it will (generallU) accelerate faster.
Note: Power to weight ratio is the weight divided
Therefore: a car with power to weight ratio of 15 should be "Less than" (or slower than) a vehicle with a ratio of 10.
The str() method returns "year make model
(power hp)
Power to Weight Ratio XX Lb/hp"
where year, make, model, and power are relevant varibles and XX is the power to weight ratio.
Use 2 decimal places for the power to weight ratio.
VVVVVVVVVVv you code below here VVVVVVVVVVVV
Transcribed Image Text:This file will contain a class called Car. The Car class takes five input parameters: year, make, model, power, weight. (Do not change these names or order) The class stores the data as attributes, and defines 5 instance methods: power_to_weight_ratio(), --eq_-), --lt__(), and --gt__(), and str() . For the less than, equal to and greater than methods you should only use the power-to-weight ratio. (Doesn't matter what their make/model/uear is) the power of the vehicle. A lower number means it will (generallU) accelerate faster. Note: Power to weight ratio is the weight divided Therefore: a car with power to weight ratio of 15 should be "Less than" (or slower than) a vehicle with a ratio of 10. The str() method returns "year make model (power hp) Power to Weight Ratio XX Lb/hp" where year, make, model, and power are relevant varibles and XX is the power to weight ratio. Use 2 decimal places for the power to weight ratio. VVVVVVVVVVv you code below here VVVVVVVVVVVV
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education