The fueled package is a Python package designed to assist in calculating and managing vehicle gas mileage, providing functionalities to compute fuel consumption, mileage, and perform unit conversions.
- Calculate fuel consumption based on distance and MPG (miles per gallon).
- Support for both city and highway MPG values.
- Convert between different units of measurement for mileage and fuel consumption.
You can install the package via pip:
pip install fueled-
year
-
This is the year of the vehicle
- Mandatory attribute
-
-
make
-
This is the manufacturer/manufacturing company of the vehicle
- Mandatory attribute
-
-
model
-
This is the specific model of the vehicle
- Mandatory attribute
-
-
transmission
-
This is the type of transmission that the vehicle has
-
The two options for this attribute are currently 'automatic' or 'manual'
-
The default value will be 'automatic' if no other value is chosen
-
Optional attribute
-
-
specs()
-
Function that returns a list of all the vehicles and specifications that match the year, make and model of the vehicle instance
-
Takes no input values
-
-
fuelConsumption( trip )
-
Function that calculates the fuel consumption of the vehicle instance. It will return a list of vehicles that match the year, make and model of the vehicle instance
-
Takes in a trip object instance to calculate the fuel consumption
-
-
distance
-
This is the total distance of the trip (miles or kilometers)
- Mandatory attribute
-
-
units
-
This is the unit of measurement that should (for miles - 'mi' / for kilometers - 'km')
-
The defualt value for units is miles - 'mi'
-
Optional attribute
-
-
-
city_driving
-
This is the amount of city driving that for the trip instance
-
Measured as a percentage value that is represented as a positive float less than the whole number 1
-
The default value for city driving is '0.55' or 55%
- It can be assumed that the difference between 1 and the city driving, will be the amount of highway driving
# Trip instance trip1 = Trip(distance=120, units='mi', city_driving=0.40) print(f'City Driving: {trip1.city_driving}') print(f'Highway Driving: {trip1.hwy_driving}')
City Driving: 0.40 Highway Driving: 0.60
-
-
milesToKilometers()
-
Function for converting trip in miles to kilometers
-
Takes no input values
-
-
kilometersToMiles()
-
Function for converting the trip in kilometers to miles
-
Takes no input values
-
- Import the 'Vehicle' and 'Trip' classes
- Create vehicle and trip instances
- Using the 'fuelConsumption()' method from 'Vehicle', calculate the fuel consumption of the vehicle instance
from fueled import Vehicle, Trip
# Provide the vehicle's details
car = Vehicle(year=2000, make='Ford', model='E150')
# Provide inputs for the trip's total distance, units of measurement and percentage of city and highway driving
trip = Trip(distance=100, units='km', city_driving=0.55)
# Call the 'fuelConsumption' method from the vehicle instance and provide the trip object to calculate the fuel consumption
fuel_consumption = car.fuelConsumption(trip)[{'_id': '16206',
'alt_fuel': 'none',
'city_mpg_fuel1': 13,
'city_mpg_fuel2': 0,
'combined_mpg_fuel1': 15,
'combined_mpg_fuel2': 0,
'cylinders': '8',
'displacement': '4.6',
'displacement_measure': 'liters',
'drivetrain': 'Rear-Wheel Drive',
'eng_id': '0',
'est_consumption_gal': 6.47,
'fuel_source': 'single fuel',
'fuel_type': 'Regular',
'has_mpg_data': 'Y',
'hwy_mpg_fuel1': 17,
'hwy_mpg_fuel2': 0,
'make': 'Ford',
'model': 'E150 Club Wagon',
'primary_fuel': 'Regular Gasoline',
'sub_cat': 'Vans, Passenger Type',
'transmission': 'Automatic 4-spd',
'year': 2000},
{'_id': '16207',
'alt_fuel': 'none',
'city_mpg_fuel1': 12,
'city_mpg_fuel2': 0,
'combined_mpg_fuel1': 13,
'combined_mpg_fuel2': 0,
'cylinders': '8',
'displacement': '5.4',
'displacement_measure': 'liters',
'drivetrain': 'Rear-Wheel Drive',
'eng_id': '0',
'est_consumption_gal': 7.42,
'fuel_source': 'single fuel',
'fuel_type': 'Regular',
'has_mpg_data': 'Y',
'hwy_mpg_fuel1': 16,
'hwy_mpg_fuel2': 0,
'make': 'Ford',
'model': 'E150 Club Wagon',
'primary_fuel': 'Regular Gasoline',
'sub_cat': 'Vans, Passenger Type',
'transmission': 'Automatic 4-spd',
'year': 2000}]