➽ Program:-

number = int(input("Enter a Binary Number(In 0s and 1s): "))

decimal_value = 0

base = 1

binary_value = number

 

while(number):

    rem = number % 10

    decimal_value += rem * base

    number = int(number / 10)

    base = base * 2

 

print("Decimal Equivalent of ",binary_value,"is",decimal_value)

➽ Output:-

Enter a Binary Number(In 0s and 1s): 10111001
Decimal Equivalent of 10111001 is 185