Convert Decimal number to octal using print() output formatting

Python / Fundamentals of Python

295

Given Input:

num = 8

Expected Output:

The octal number of decimal number 8 is 10

Hint:

Use the %o formatting code in print() function to format decimal number to octal.

Program:

num = 8
print('%o' % num)

Output:

10

This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.