Python oct()

Configurare noua (How To)

Situatie

The oct() function takes an integer number and returns its octal value.

Solutie

Pasi de urmat

# decimal to octal
print(‘oct(10) is:’, oct(10))

# binary to octal
print(‘oct(0b101) is:’, oct(0b101))

# hexadecimal to octal
print(‘oct(0XA) is:’, oct(0XA))

Output:

oct(10) is: 0o12
oct(0b101) is: 0o5
oct(0XA) is: 0o12

Tip solutie

Permanent

Voteaza

(5 din 19 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?