## Question Reference

Python Home

### Python Methods

Python String Methods

### Python Interview Programs

Python Common ProgramsPython Array ProgramsPython Converter ProgramsPython Star Patterns ProgramPython Number Patterns ProgramPython Alphabet Patterns Program

ASCII Table

# Python Program to Converter a Binary to Decimal

Last Updated:

## Converter a Number from Binary to Decimal

In the following example, we will convert a Binary number (1000001) to a Decimal number (65).

Tips: It is recommended to use our online Binary to Decimal converter for better understanding.

### Example

Python Compiler
import math num = 1000001 arr = *50 i = -1 total = 0 while(num != 0): i += 1 arr[i] = num % 10 num = math.floor(num / 10) for j in range(i, -1, -1): total += arr[j] * math.pow(2, j) print("Decimal number of 1000001 (binary) is %d" % math.floor(total))

## Converter any Given Binary Number to Decimal Number

In the following example, we will convert any given binary number to a decimal number.

### Example

Python Compiler
import math num = int(input("Enter a Binary Number: ")); copyNum = num arr = *50 i = -1 total = 0 while(copyNum != 0): i += 1 arr[i] = copyNum % 10 copyNum = math.floor(copyNum / 10) for j in range(i, -1, -1): total += arr[j] * math.pow(2, j) print("Decimal number of %d (binary) is %d" % (num, math.floor(total)))

## Meet the Author

### Basic Tools

Javascript KeycodeCase ConverterRemove Line Breaks