Skip to main content

A simple averager

Project description

averager

GitHub license

A simple way to average numbers in Python.

Averager

Averager is the base class of the averager module. To use the Averager class, create an instance (no parameters are needed), then use the average method to average your numbers.

import averager
instance = averager.Averager
instance.average(1, 5)
# returns 3

WeightedAverager

WeightedAverager allows you to set different weights for the numbers you average. Initalize an instance of the WeightedAverager class using keyword arguments to set weights to labels which will be used later on. A weight with a value of 1 is normal. Then, once you define an instance, call its average method, passing keyword arguments with your labels and values.

import averager
instance = averager.WeightedAverager(a=1, b=2, c=3) # This sets a to be 1x, b to be 2x, and c to be 3x.
instance.average(a=1, c=2) # This passes 1 as a and 2 as c, so 2 has 3x the weight of 1.
# returns 1.75

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

averager-1.0.1.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

averager-1.0.1-py3-none-any.whl (14.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page