efinf:blcks2017:bitsundbytes:logischeoperatoren

Wahrheitstabellen

truthtable.py
def truthTable(op,numvar,title):
    print title
    print "-"*8*(numvar+2)
    for v in range(1 << numvar):
        l=[]
        for i in range(numvar):
            l.append((v>>i & 1)==1);
            print l[-1],
            print "\t",
        print "|\t",op(l)
    print
 
truthTable(lambda x:not x[0],1,"A\t|\tnot A");
truthTable(lambda x:x[0] and x[1],2,"A\tB\t|\tA and B");
truthTable(lambda x:x[0] or x[1],2,"A\tB\t|\tA or B");

Spielen mit logischen Schaltungen: http://www.cburch.com/logisim/ oder online https://simulator.io/board

  • efinf/blcks2017/bitsundbytes/logischeoperatoren.txt
  • Last modified: 2017/09/26 12:01
  • by Ivo Blöchliger