Skip to content

Commit acc4db3

Browse files
authored
Create Binary To Decimal DHEERAJHARODE#2746
1 parent 1c86990 commit acc4db3

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)