codescracker


python

Python Program to Convert Octal to Decimal



« Previous Program Next Program »


Convert Octal to Decimal in Python

To convert octal to decimal number in python, you have to ask from user to enter a number in octal number system to convert it into decimal number to display the equivalent number in decimal format as shown in the program given below.

Python Programming Code to Convert Octal to Decimal

Following python program ask from user to enter any number in octal number system to convert it into decimal number:

# Python Program - Convert Octal to Decimal

print("Enter 'x' for exit.");
octal = input("Enter number in Octal Format: ");
if octal == 'x':
    exit();
else:
    decimal = str(int(octal, 8));
    print(octal,"in Decimal =",decimal);

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

octal to decimal python

Above is the inial output, now enter a number in octal to convert the same number in decimal form after pressing the enter key as shown here in below sample output:

convert octal to decimal python

Here is the same program with run on python shell:

python convert octal to decimal

Program Video with Compile and Run

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