Friday 24 September 2021

Python: Convert integer value to octal

‘oct’ function is used to convert an integer number to an octal string prefixed with “0o”.

 

Example

res2 = oct(9)

 

Find the below working application.

 

oct_demo_1.py

res1 = oct(8)
res2 = oct(9)
res3 = oct(10)

print(res1)
print(res2)
print(res3)

Output

0o10
0o11
0o12

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment