Skip to content

Commit d95557e

Browse files
authored
Merge pull request #1 from JsMelix/JsMelix-patch-1
Create Binary To Decimal DHEERAJHARODE#2746
2 parents 1c86990 + acc4db3 commit d95557e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Binary To Decimal #2746

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def binary_to_decimal(binary):
2+
decimal = 0
3+
for digit in binary:
4+
decimal = decimal * 2 + int(digit)
5+
return decimal
6+
7+
binary = input("Enter binary number: ")
8+
print("Decimal number:", binary_to_decimal(binary))

0 commit comments

Comments
 (0)