Decode resistor color codes and encode resistance values
Project description
Resistors
A Python library for decoding resistor color codes and encoding resistance values.
- Converts colors to value
- Converts value to colors
- Supports four and five-band resistors
- Zero dependencies
The library strictly follows the following chart:
Any colors used in a program not included in this chart will result in a KeyError
.
Installation
pip3 install resistors
Usage
from resistors import Resistor
r1 = Resistor("red", "red", "black", "black", "brown")
print(r1.get_resistance()) # {'value': 220.0, 'tolerance': 1.0}
r2 = Resistor.with_resistance(1230, 2, 5) # create resistor object with value of 1230Ω, tolerance of +-2%, and 5 bands
print(r2.get_colors()) # ['brown', 'red', 'orange', 'brown', 'red']
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
resistors-1.0.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for resistors-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a64301a2be0732c0e5bfd6cc62e2a48b4f9d15bc4fcf043c770ec0a36c353803 |
|
MD5 | b9eb29d4acd50cbef0e1dbcaa80a31e1 |
|
BLAKE2b-256 | a61da6879545fd7f73d0b914a574925ba83ee41cb8215e9894bcc0b6c01c36b5 |