To convert binary to octal number in python, you have to ask from user to enter a number in binary number system to convert that number into octal number system as shown in the program given below.
Following python program ask from user to enter binary number to convert it into octal number:
# Python Program - Convert Binary to Octal while True: print("Enter 'x' for exit.") binary = input("Enter number in Binary Format: ") if binary == 'x': break else: temp = int(binary, 2) print(binary,"in Octal =",oct(temp),"\n")
Here is the sample run of the above Python program to demonstrate how to convert binary to octal number:
You may also like to learn or practice the same program in other popular programming languages: