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)

Recommended Answers

All 5 Replies

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".

griswolf beat me to it :)

Merged duplicate threads...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.