Here we will see how to easily add two numbers in python3 using built-in functions.

please run this program with python3.

**Steps:**

**1.**Take input of the two binary numbers as string using the input function.

**2.**convert them into integers using int function passing the base 2

**3.**Add the integers

**4.**convert the sum into binary using the bin function

Same steps for subtracting, multiplication, or division, just change the operation in

**step 3**

a = input("Enter 1st binary number: ") b = input("Enter 2nd binary number: ") #converting a and b into integer a = int(a,2) b = int(b,2) #adding the integers s = a + b #sonverting the sum into binary s = bin(s) print(s)

You can take this Python Quiz

Tweet

## No comments:

## Post a Comment