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.
Following python program ask from user to enter octal number and convert that number into binary number:
# Python Program - Convert Octal to Binary print("Enter 'x' for exit."); octal = input("Enter any number in Octal Format: "); if octal == 'x': exit(); else: dec = str(int(octal, 8)); decm = int(dec); print(octal,"in Binary =",bin(decm));
Here is the sample run of the above Python program demonstrating how to convert any octal number into binary number:
Now enter any number in octal and press enter to see the same number in binary as shown here in below screenshot:
Here is the same program with run on python shell:
Program Video with Compile and Run
You may also like to learn or practice the same program in other popular programming languages: