Convert Decimal number to octal using print() output formatting
Convert Decimal number to octal using print() output formatting
Convert Decimal number to octal using print() output formatting
num = 8
The octal number of decimal number 8 is 10
Use the %o formatting code in print() function to format decimal number to octal.
num = 8
print('%o' % num)
10
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.