Welcome folks today in this blog post we will be
implementing half subtractor in digital logic in python. All the full source code of the application is shown below.
In order to get started you need to make an
app.py file and copy paste the following code
# Python program to implement Half subtractor # Function to print Difference and Borrow def getResult(A, B): # Calculating value of Difference Difference = A ^ B # Calculating value of Borrow # calculating not of A A = not(A) Borrow = A & B # printing the values print("Difference:", Difference) print("Borrow:", Borrow) # Driver code # Inputs A ,B A = 0 B = 1 # passing two inputs of halfadder # as arguements to get result function getResult(A, B)
Now if you execute the
python script by typing the below command as shown below