Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Estimate the engine horsepower of a vehicle based on the weight of the vehicle and

the speed at which the vehicle finished a quarter mile.

Use The Trap-Speed Method to make estimation This method uses the vehicle weight a
nd the speed at which the vehicle
finished a quarter mile on the formula of Horsepower = Weight*((Speed/234)**3).

SUB-TASK-1
You need to create "Vehicle" class with three attributes "model" , "weight" and "s
peed"
they will be provided as parameters to __init__

example model : "BMW M3"


example weight(in kilograms): 2735 note: weight can not be negative so in __init__
method, call setter method
to be able to assign its value, inside setter method check whether it is negative
or not if it is negative make the
weight equals to 1524 kg which is mid-size car average weight
example speed : 90

"model" , "weight" and "speed" attributes


should be private and should have appropriate getter-setter methods whether via pr
operty function or property decorator

You need to implement a "hp" method that returns estimated engine power (use only
one digit after decimal point)
calculated by The Trap-Speed Method

You need to implement a __str__ method which returns string that includes details
of model,weight and speed

SUB-TASK-2
Declare two sub-classes which inhereted from Vehichle class, GasolinePowered and E
lectricPowered are names for these
two classes

Define appropriate __init__ methods for each class which accepts "model" , "weight
" and "speed" attributes and passes
them to parent(base or super) class

You need to implement a __str__ method for each class which returns string that in
cludes details of Vehicle Type
(Whether it is Gasoline Powered or Electric Powered),model,weight,speed and calcul
ated power according to appropriate unit.(hp or kw)

You need to implement a "watt" method in ElectricPowered class which obtains horse
power and converts
that value to kWh using 1 hp = 745.699872 watt and 1000 watt = 1 kW(use only one d
igit after decimal point)
and returns it.

Create two objects, one for GasolinePowered and one for ElectricPowered and print
both of objects.

You might also like