codescracker


python

Python Program to Convert Octal to Binary



« Previous Program Next Program »


Convert Octal to Binary in Python

To convert octal to binary in python, you have to ask from user to enter any number in octal format to convert that number in binary number system as shown in the program given here.

Python Programming Code to Convert Octal to Binary

Following python program ask from user to enter octal number and convert that number into binary number:

# Python Program - Convert Octal to Binary
		
while True:
	print("Enter 'x' for exit.")
	octal = input("Enter number in Octal Format: ")
	if octal == 'x':
		break
	else:
		dec = str(int(octal, 8))
		decm = int(dec)
		print(octal,"in Binary =",bin(decm),"\n")

Here is the sample run of the above Python program demonstrating how to convert any octal number into binary number:

python convert octal to binary

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