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)
Python Code to Convert Binary to Decimal Without Inbuilt Function
binary_str = input('Enter a Binary number to convert it to Decimal: ')
digit_list = list(binary_str)
digit_list.reverse()
sum = 0
for digit in (range(len(digit_list))):
sum = sum + int(digit_list[digit]) * pow(2, digit)
print(sum)
binary_str = input("Enter a Binary number to convert it to Decimal :")
decimal_num = int(binary_str, 2)
print(decimal_num)