Skip to content

Commit ecb238e

Browse files
Merge pull request #22 from VijayGomathi/master
#11 Added a python program to convert the Integer to binary equivalent
2 parents 72e3554 + 3286675 commit ecb238e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python
2+
3+
4+
def convertToBinary( num ):
5+
"function to convert integer to equivalent binary string"
6+
if (num > 1):
7+
convertToBinary(num/2)
8+
print(int(num%2), end="")
9+
return;
10+
11+
# Getting inpts from user
12+
num = input('Enter the integer: ')
13+
14+
# passing the input to convertToBinary method
15+
print('The binary equivalent of {0} is '.format(num), end='' )
16+
convertToBinary(int(num))

0 commit comments

Comments
 (0)