codescracker


python

Python Program to Convert Binary to Decimal



« Previous Program Next Program »


Convert Binary to Decimal in Python

To convert binary to decimal number in python, you have to ask from user to enter a number in binary number system to convert that number into decimal number system as shown in the program given here.

Python Programming Code to Convert Binary to Decimal

Following python program ask from user to enter binary number to convert it into decimal number:

# Python Program - Convert Binary to Decimal
		
while True:
	print("Enter 'x' for exit.")
	binary = input("Enter number in Binary Format: ")
	if binary == 'x':
		break
	else:
		decimal = int(binary, 2)
		print(binary,"in Decimal =",decimal,"\n")

Here is the sample run of the above Python program shows how to convert binary number to decimal number:

python convert binary to decimal

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test