Skip to content

Commit

Permalink
Merge pull request #1 from JsMelix/JsMelix-patch-1
Browse files Browse the repository at this point in the history
Create Binary To Decimal DHEERAJHARODE#2746
  • Loading branch information
JsMelix authored Oct 17, 2024
2 parents 1c86990 + acc4db3 commit d95557e
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 d95557e

Please sign in to comment.