Professional Documents
Culture Documents
Python Labwork
Python Labwork
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__
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.