Skip to content

Commit

Permalink
Create Binary To Decimal DHEERAJHARODE#2746
Browse files Browse the repository at this point in the history
  • Loading branch information
JsMelix authored Oct 17, 2024
1 parent 1c86990 commit acc4db3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Binary To Decimal #2746
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def binary_to_decimal(binary):
decimal = 0
for digit in binary:
decimal = decimal * 2 + int(digit)
return decimal

binary = input("Enter binary number: ")
print("Decimal number:", binary_to_decimal(binary))

0 comments on commit acc4db3

Please sign in to comment.