Question: Here is the Python code for our Truth Table Generator function truthTable ( ) which takes two parameters: A Boolean expression: e . g .
Here is the Python code for our Truth Table Generator functiontruthTablewhich takes two parameters:
A Boolean expression: eg A AND NOT B OR C
The number of inputs: either or : A B C and D
#Truth Table Generator wwwcomputing.nettruthtablegenerator
def truthTableexpressioninputs:
printBoolean Expression:"
print X expression.upper
expression expression.lower
#replace Boolean Operators with bitwise operators
expression expression.replaceand&
expression expression.replacexor
expression expression.replaceor
expression expression.replacenot~
print
Truth Table:"
if inputs:
print
print A B X
print
for a in range:
for b in range:
x evalexpression
print stra strb strx
print
elif inputs:
print
print A B C X
print
for a in range:
for b in range:
for c in range:
x evalexpression
print stra strb strc strx
print
elif inputs:
print
print A B C D X
print
for a in range:
for b in range:
for c in range:
for d in range:
x evalexpression
print stra strb strc strd strx
print
##############################################
expression "A AND NOT B XOR C
truthTableexpression
Your Task
Write an additional function to perform a bitwise left shift or a bitwise right shift using the bitwise operators and
Check that performing aleft shift by n placesis equivalent tomultiplying a number by n
For instance is the same as times
Check that performing aright shift by n placesis equivalent todividing a number by nwhole division
For instance is the same as
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
