I'm new to python ,please tell me the way to write a program using python , to convert any decimal number into octal number(base 8) (using python 2.7)

Edited by Ezzaral: Fixed title

7 Years
Discussion Span
Last Post by casper1

Divide by 8 and reverse the remainders.

Don't steal other's thread, please but start new one of your own!


The main thing is to be clear in your own mind about what you are doing. You are not "converting a decimal number". What you want to do is display a number in octal. This is done by formatting the number. The big hammer is built-in function format which uses a format specification mini-language, but you can also get the job done using simple string formatting

Note that the documentation says that the more powerful formatting technique I first mentioned is to be preferred "for new code".


I'm sorry ,i dont' know this is a duplicate one : i'm newbie very sorry :thanx for inform me :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.