Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Binary to decimal in Python without inbuilt function

binary_num = int(input("Enter the Binary Number: "))
dec_num = 0
m = 1
length = len(str(binary_num))

for k in range(length):
    reminder = binary_num % 10
    dec_num = dec_num + (reminder * m)
    m = m * 2
    binary_num = int(binary_num/10)

print("Equivalent Decimal Value = ", dec_num)
Source by pythonguides.com #
 
PREVIOUS NEXT
Tagged: #Binary #decimal #Python #inbuilt #function
ADD COMMENT
Topic
Name
3+9 =