Python program for decimal to octal conversion

Decimal to octal conversion

Here, in this section we will discuss the program for decimal to octal conversion in python. Decimal numbers are the standard representation for representing integer or non-integer values. Decimal numbers are with base 10 and can represent numbers from 0-9. Whereas in Octal representation of numbers, numbers from 0-7 are represented as octal numbers are with base 8. In this python program, we will convert decimal numbers to octal numbers using oct() function.

Decimal to octal conversion in python


  • Step 1:- Start.
  • Step 2:- Take decimal number.
  • Step 3:- Convert decimal to octal using oct() function.
  • Step 4:- Print octal representation of number.
  • Step 5:- End.
Python program to convert decimal to octal number

Program for Decimal to Octal conversion in Python :

#take decimal number
Dec_num = 598
#convert using oct() function
Oct_num = oct(Dec_num)
#print number
print('Number after conversion is :' + str(Oct_num))
Number after conversion is :0o1126