adding binary numbers in Python

 Question :-

How do I add binary numbers in Python?

adding binary numbers in Python

it is little bit logical but not too tough so we have to understand firts of all how to convert binary to decimal and decimal to binary and many more conversion.
so if you want to add two binary number then first of all convert your decimal number into binary and simply add it.
Let’s see an example of it.
Example:-
x,y=0b1010,0b1011
add=int(x[2:])+int(y[2:])
print(bin(add))


Comments

Popular posts from this blog

Proassignmenthelp index 27

HackerRank Question: Print Function

Programmingshark index 18