Skip to content

Commit e29c7f9

Browse files
Merge pull request raviprakashdev#57 from SnehaRautmare/feature/add-binary
Add code for addition of binary numbers
2 parents 73a291a + c8ad284 commit e29c7f9

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Add_Binary.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
def addBinary(num1: str, num2: str) -> str:
3+
"""
4+
Method to add to binary numbers
5+
Parameters: Two binary numbers num1 and num2 (string)
6+
Output: Addition in binary
7+
"""
8+
sumnum = int(num1,2) + int(num2,2)
9+
print(bin(sumnum)[2:])
10+
11+
addBinary("11", "1")

0 commit comments

Comments
 (0)