[Tutor] Inheritance in Python

Manprit Singh manpritsinghece at gmail.com
Thu Sep 10 08:46:43 EDT 2020


Dear Sir ,

Before starting to explain my problem, first i would like to explain some
basic concepts related to my problem .

Python bitwise AND Operator :
x & y   --- Will result  in 1 if  both x and  y are 1, else  0

Python bitwise Exclusive or operator :
x ^  y --- Will result  in  0 if  both x  and y are same , else 1

provided value of x  and y can be either  0 or 1.

Now let us see what is a half adder :
half adder is a combinational logic circuit , which can generate Sum and
Carry output for 2 input  bits . Table given below describes the output of
half adder

Inp1    Inp2       SUM        Carry
0         0             0              0
0         1             1              0
1         0             1              0
1         1             0              1

It is clear from the table that  SUM  bit is generated with bitwise
Exclusive OR and Carry bit is generated with bitwise AND .

So coming to the question,  IF  there are two classes one for bitwise AND
and second for bitwise Exclusive OR operation. and i have to make a class
for half adder , if i am not wrong i can use inheritance for deriving a
new  class for half adder from existing classes  of bitwise AND and Bitwise
OR operation.

Need your guidance .

Regards
Manprit singh


More information about the Tutor mailing list