Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bin_dec(binary):
- decimal = 0
- i = 0
- while (binary != 0):
- rem = binary % 10
- last_digit = rem * pow(2,i)
- decimal = decimal + last_digit
- binary = binary // 10
- i += 1
- return decimal
- num = int(input("Enter binary number"))
- result = bin_dec(num)
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement