I made a simple circuit with Python (AND, OR, NOR, etc.)

Previous article

code

Kairo.py


class Kairo:
  def And(self,x,y):
    return (x and y)
  
  def Or(self, x, y):
    return (x or y)
  
  def Not(self, x):
    return (not x)
  def Nor(self, x, y):
    return self.Not(self.Or(x, y))
  
  def Nand(self, x, y):
    return self.Not(self.And(x, y))
  
  def Xor(self, x, y):
    return self.Or(self.And(x, self.Not(y)), self.And(self.Not(x), y))

main.py


import Kairo

kairo = Kairo.Kairo()

print(kairo.Xor(False, False))
print(kairo.Xor(True, False))
print(kairo.Xor(True, True))


$ python main.py
False
True
False

Impressions

I want to make a half adder this time

Recommended Posts

I made a simple circuit with Python (AND, OR, NOR, etc.)
I made a simple blackjack with Python
I made a LINE BOT with Python and Heroku
I made a fortune with Python.
I made a daemon with Python
I made a simple typing game with tkinter in Python
I made a simple book application with python + Flask ~ Introduction ~
I made a character counter with Python
I made a Hex map with Python
I made a roguelike game with Python
I made a configuration file with Python
I made a neuron simulator with Python
I made a Nyanko tweet form with Python, Flask and Heroku
[Python] I made an image viewer with a simple sorting function.
I made a competitive programming glossary with Python
I made a weather forecast bot-like with Python.
I made a GUI application with Python + PyQt5
I made a Twitter fujoshi blocker with Python ①
[Python] I made a Youtube Downloader with Tkinter.
I made a simple Bitcoin wallet with pycoin
I made a bin picking game with Python
I made a Mattermost bot with Python (+ Flask)
I made a Twitter BOT with GAE (python) (with a reference)
I made a Christmas tree lighting game with Python
I made blackjack with python!
I made a net news notification app with Python
Let's make a simple game with Python 3 and iPhone
I made a Python3 environment on Ubuntu with direnv.
I made a python text
I made blackjack with Python.
I made wordcloud with Python.
I made a program to convert images into ASCII art with Python and OpenCV
A simple interactive music player made with Chuck and OpenPose
I made a package to filter time series with python
I made a puzzle game (like) with Tkinter in Python
I made a Chatbot using LINE Messaging API and Python
I made a Line-bot using Python!
I played with PyQt5 and Python3
[Python] return A [or / and] B
I made a server with Python socket and ssl and tried to access it from a browser
I made a library to easily read config files with Python
[Python3] I made a decorator that declares undefined functions and methods.
I made a simple network camera by combining ESP32-CAM and RTSP.
I made a package that can compare morphological analyzers with Python
Make a simple OMR (mark sheet reader) with Python and OpenCV
I made a lot of files for RDP connection with Python
I tried to make a periodical process with Selenium and Python
I made a shuffle that can be reset (reverted) with Python
I made a poker game server chat-holdem using websocket with python
I made a segment tree with python, so I will introduce it
Create a simple Python development environment with VS Code and Docker
I made a Chatbot using LINE Messaging API and Python (2) ~ Server ~
I made a chatbot with Tensor2Tensor and this time it worked
Creating a simple PowerPoint file with Python
A simple RSS reader made with Django
I made a payroll program in Python!
Simple Slack API client made with Python
I drew a heatmap with seaborn [Python]
A memo with Python2.7 and Python3 on CentOS
Connect a lot of Python or and and
I tried a functional language with Python