Skip to content

Commit 708241f

Browse files
Create decimal to binary
it will convert all decimal numbers to binary
1 parent 8682a38 commit 708241f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

decimal to binary

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def decimalToBinary(num):
2+
"""This function converts decimal number
3+
to binary and prints it"""
4+
if num > 1:
5+
decimalToBinary(num // 2)
6+
print(num % 2, end='')
7+
8+
9+
# decimal number
10+
number = int(input("Enter any decimal number: "))
11+
12+
decimalToBinary(number)

0 commit comments

Comments
 (0)