Skip to main content

No project description provided

Project description

gatepy

made-with-python PyPI license PyPI version shields.io PyPI pyversions

gatepy is a Python implementation of a logical gate.

Installation

Open console and run the following command:

pip install gatepy

Done.

Examples

Adder

import gatepy

def adder(a,b):
    c = '0'
    a = list(format(a, '016b'))[::-1]
    b = list(format(b, '016b'))[::-1]
    out = []
    for i in range(16):
        S = gatepy.toint(gatepy.XOR(gatepy.XOR(gatepy.tobool(a[i]), gatepy.tobool(b[i])), gatepy.tobool(c)))
        c = gatepy.OR(gatepy.AND(gatepy.XOR(gatepy.tobool(a[i]), gatepy.tobool(b[i])), gatepy.tobool(c)),gatepy.AND(gatepy.tobool(a[i]),gatepy.tobool(b[i])))
        out.append(str(S))
    return int(''.join(out[::-1]), 2)

print(adder(1,2))

Return:

3

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

gatepy-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file gatepy-1.0.1.tar.gz.

File metadata

  • Download URL: gatepy-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for gatepy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f14e2f1c171d9bd08d3881eb2870bea211a749707e5041142e9394e200bfc013
MD5 ef019efb223d1c883794701b73c4b56f
BLAKE2b-256 8c1dd7c8164ef280cd7bd17fd246029a31b51c06fa4a68e3727385cc760b1cef

See more details on using hashes here.

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