Python Code Example: convert decimal to octal number

LineDescription
1Function header of the function decToOct() with the input parameter x
2Returns the octal representation of the number x. The oct() function normally returns a string in the following form: ‘0o….’. The function .split() removes the substring 0o from the string
4Calls the function decToOct() with the parameter 125 and prints the result
def decToOct(x):
    return oct(x).split('o')[-1]

print(decToOct(125))
Output
175