A Python package for vehicle mileage calculations
Project description
Fueled
The fueled package is a Python library designed to assist in calculating and managing vehicle gas mileage, providing functionalities to compute fuel consumption, mileage, and perform unit conversions.
Features
- 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.
Installation
You can install the package via pip:
pip install fueled
Usage
Vehicle and Trip objects
Vehicle:
Attributes:
-
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
-
Methods:
-
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
-
Trip:
Attributes:
-
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
Example:
# 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
-
Methods:
-
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
-
Example
- 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}]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fueled-0.0.4.tar.gz.
File metadata
- Download URL: fueled-0.0.4.tar.gz
- Upload date:
- Size: 976.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b3ff2fae63e68ae614699440aefc98eaaa25aa3a4c2b8fdf429be419d51cd2d
|
|
| MD5 |
81ab855b7a12c6fd57b5784dec1050bb
|
|
| BLAKE2b-256 |
eeb33ad9e26c1b4e39016993850625505bf11a2d8ae2d58bbc81f0a821e066cb
|
File details
Details for the file fueled-0.0.4-py3-none-any.whl.
File metadata
- Download URL: fueled-0.0.4-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f48249a574a914172f0b177948818267bfdc2656be2610a7c51503405957312
|
|
| MD5 |
0714170400340e1d6d7fcac5c6fabd15
|
|
| BLAKE2b-256 |
9b813e55576f8d0056b9bd08102f48060dce18430b04aa3a54bd8f07445d396c
|