Python Program:

- To convert binary number into decimal

Example:

User Input: In Binary : 100

Output: In decimal : 4

def toDecimal(num) :
  n=i=0
  while(num!=0):
    if(num%10==0 or num%10==1) :
      n=n+(2**i)*(num%10)
      i+=1
    else :
      print("Number is not in binary form ")
      return 0
    num=num//10
  return n

num=int(input("Enter Your binary Number :"))
print("Number in decimal : ",toDecimal(num))

Output:

  Enter Your binary number : 1101
  Number in decimal : 13
Program
number

Binary Numbers : Numbers with only 0 & 1 combination

Examples like: 101, 111, 10, 11111

Main Logic :

def toDecimal(num) :
  n=i=0
  while(num!=0):
    if(num%10==0 or num%10==1) :
      n=n+(2**i)*(num%10)
      i+=1
    else :
      print("Number is not in binary form ")
      return 0
    num=num//10
  return n
  Calculation:
  Lets take binary number n=100

  = 20*0 + 21*0 + 22*1
  = 0 + 0 + 4
  = 4

------------------------------------------------------------------------
  take every single digit of your binary number from right side and
  multiply it with 2 to the power of index position 
  starting form 0 at the right side 

  Index position  2 1 0
                  | | |
  Binary Number   1 0 0 
Concept

Coming Soon !

Quick
Tutorial

Quote

The best preparation for good work tomorrow is to do good work today.