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