Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 4b84eee

Browse files
committed
binary to decimal conversion
1 parent 07f497a commit 4b84eee

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Binary to Decimal Conversion
3+
"""
4+
5+
6+
def binary_to_decimal(n):
7+
main = 0
8+
temp = 1
9+
10+
while (n > 0):
11+
12+
y = n % 10
13+
main += temp * y
14+
temp *= 2
15+
n //= 10
16+
17+
return main
18+
19+
20+
if __name__ == "__main__":
21+
22+
n = int(input("Entre number"))
23+
print(binary_to_decimal(n))

0 commit comments

Comments
 (0)