Python 3 Script to Implement Half Adder in Digital Logic

Python 3 Script to Implement Half Adder in Digital Logic

Python 3 Script to Implement Half Adder in Digital Logic

# Function to print sum and carry
def getResult(A, B):
    
    # Calculating value of sum
    Sum = A ^ B
    
    # Calculating value of Carry
    Carry = A & B
    
    # printing the values
    print("Sum ", Sum)
    print("Carry", Carry)


# Driver code
A = 0
B = 1

# passing two inputs of halfadder as arguements to get result function
getResult(A, B)
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment