number_comparator
A numeric comparator package, built by Diego Ramirez.
Introduction
The number_comparator package can compare if a number is a:
- Prime
- Pair
- Periodic
- Multiple of a specific number (new since version 0.0.4)
Also, you can operate:
- Average from:
- Tuples
- Lists (new since version 0.0.5)
- Reverse numbers from:
- Integers
- Float
To obtain the package with pip, use one of this commands:
pip install number_comparator
pip install number_comparator_[version]_[plat].whl
pip install number_comparator_[version].tar.gz
pip install number_comparator==[version]
pip install --upgrade number_comparator
Release notes
What's new in number_comparator 0.0.5
- More accurate functions
- Some operations corrected or added at function
isMultiple()
- Some operations corrected or added at function
- New functions
averageFromList(). View description to learn more.
What's new in number_comparator 0.0.4
- New features
- Variable
__license__ - New function:
isMultiple()
- Variable
What's new in number_comparator 0.0.3
- Minor bugs resolved
__version__variable fixed- Some variables fixed at
number_comparator.data.first_prime - Some operations fixed at
number_comparator.operations:- Cleaner functions
- New MANIFEST.in includes:
- The
setup.py - The license file
LICENSE - The markdown file
README.md
- The
Using number_comparator functions
To call the number_comparator library, just type:
from number_comparator import *
isPair()
The function isPair(n) takes a number and returns True if the number is a
pair or False if not. So, if you type:
print(isPair(20)) # Short number
print(isPair(15)) # Short number
print(isPair(1986031)) # Large number?
You'll get this output:
True
False
False
isPrime()
The prime numbers are numbers that can only be divided by 1 and themselves. To find if a number is prime, we used many functions:
- Check if a number is on a list of 168 prime numbers.
- If the number is larger, check if the termination is 1, 3, 7 or 9
Example: 3, 4, 7.
print(isPrime(3))
print(isPrime(4))
print(isPrime(7))
You must get:
True
False
True
NOTE: The function isPrime() does not support negative numbers. You can convert them
by using the reverseNumber() function to operate it later.
reverseNumber()
The reverseNumber() function converts a negative number to a positive number, and a
positive to a negative. The allowed data type is int().
print(reverseNumber(123))
print(reverseNumber(-123))
So, conversions must be:
| Before | After |
|---|---|
| 123 | -123 |
| -123 | 123 |
To convert float numbers, use reverseFloat().
reverseFloat()
This function has the same function than reverseNumber(), but taking a float number:
print(reverseNumber(1.23))
print(reverseNumber(-1.23))
isPeriodic()
In Python, periodic numbers are infinite float numbers. We are using this property to see if a number (int or float) is periodic.
For example, 10 / 3 returns a periodic float():
print(isPeriodic(10 / 3))
So you'll get the output:
True
average()
Take an average from a tuple or a group of numbers:
print(average(10, 7, 8, 9)) # As a multiple argument group
Getting the output:
8.5
isMultiple()
Check if a number is a multiple of another number with syntax:
isMultiple(a, b)
Here, value a is the one to be checked, and b is the expected divisor. Taking
this explanation, check the example:
print(isMultiple(15, 5))
print(isMultiple(35, 4))
And you must receive output:
True
False
NOTE: Function isMultiple() only accepts integers. If you enter complex
or float numbers, function will raise a TypeError. Check this example:
print(isMultiple(complex(12, 98), 23.87)) # A complex as 'a' and a float as 'b'
Traceback (most recent call last):
File .../.../.py, line ..., at <module>
print(isMultiple(complex(12, 98), 23.87))
File .../site-packages/number_comparator/comparisons.py, line 62, at isMultiple
raise TypeError(
^
TypeError: Expected int numbers, got values: 12, 98j | 23.87
NOTE: At parameter b, isMultiple() only accepts numbers positive numbers
larger than 0. Also, when using 1 as b, you'll receive:
warnings.warn(msg)
0298274hde5t43.UserWarning: When using 1 as divisor (arg 2), you will always get True.
We are returning True immediately to save variables.
averageFromList()
This function takes a list, extract the numbers, and return the average from them.
Example:
a = [10, complex(12, 8), "dummy string", 9.53, 8, {"a": None}]
print(averageFromList(a))
9.17666666666666666
At this example, the function ignored the string "dummy string", dictionary {"a": None}
and the complex complex(12, 8). It only takes integers or float numbers.
Metadata
Release files for number-comparator 0.0.5.post1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| number_comparator-0.0.5.post1.tar.gz | 9.7 kB | Without provenance | Details for number_comparator-0.0.5.post1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| number_comparator-0.0.5.post1-py3-none-any.whl | Python 3 | none | any | Details for number_comparator-0.0.5.post1-py3-none-any.whl |
Total release size: 18.3 kB
Release files / number_comparator-0.0.5.post1.tar.gz
| Download URL | number_comparator-0.0.5.post1.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a4ac68cb0b2f7de230355a1970c6f7371e3a8fb1128073eeeb75dfa9918d882
|
|
BLAKE2b-256 checksum How to use checksums |
c5903a9c99a0001da3baee8b7bbfb71cfd26aa606808fcf7d7d202baf18e2ecb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
|
Release files / number_comparator-0.0.5.post1-py3-none-any.whl
| Download URL | number_comparator-0.0.5.post1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc1028cdc3972747592bbb8e4f2e5435eb49c9dfa20bd131c8164e21b5e21be6
|
|
BLAKE2b-256 checksum How to use checksums |
92b5c915b0312115bac81952c696d25f85098122c408af6d36f4687d94c39473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.2
|
Security for number-comparator 0.0.5.post1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.