basic
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
Supported Ubuntu and Python Versions
[!NOTE|label:references:]
NOTE: Python2.7 (all), Python 3.6 (bionic), Python 3.8 (focal), Python 3.10 (jammy) are not provided by deadsnakes as upstream ubuntu provides those packages.
python 2.3
✔
python 2.4
✔
python 2.5
✔
$ python -c 'help("modules")'
Please wait a moment while I gather a list of all available modules...
__future__ _warnings graphlib runpy
_abc _weakref grp sched
_aix_support _weakrefset gzip secrets
...
$ python -c 'import sys; print (sys.path)'
['', '/usr/lib/python39.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
octal to binary
>>> bin( int('0o10', 8) )
'0b1000'
>>> bin( int('0o17', 8) )
'0b1111'
decimal to binary
>>> bin(2)
'0b10'
>>> bin(10)
'0b1010'
or
>>> format( 3, 'b' )
'11'
>>> format( 15, 'b' )
'1111'
hexadecimal to binary
>>> bin( int('a', 16) )
'0b1010'
>>> bin( int('f', 16) )
'0b1111'
binary to octal
>>> oct( int(str(111), 2) )
'0o7'
>>> oct( int(str(1000), 2) )
'0o10'
decimal to octal
>>> oct(8)
'0o10'
or
>>> format( 15, 'o' )
'17'
>>> format( 8, 'o' )
'10'
hexadecimal to octal
>>> oct( 0xf )
'0o17'
binary to decimal
>>> int( str(11), 2 )
3
>>> int( str(1010), 2 )
10
octal to decimal
>>> 0o10
8
>>> int( 0o10 )
8
>>> int ( str(10), 8 )
8
hexadecimal to decimal
>>> int( 0xf )
15
binary to hexadecimal
>>> hex( int(str(1010), 2) )
'0xa'
>>> hex( int(str(1111), 2) )
'0xf'
octal to hexadecimal
>>> hex(0o10)
'0x8'
>>> hex( int('0o17', 8 ))
'0xf'
decimal to hexadecimal
>>> hex(15)
'0xf'
>>> hex(66)
'0x42'
[!NOTE|label:references:]
python 2.6
✔
python 2.7
✔
python 3.1
✔
python 3.2
✔
python 3.3
✔
python 3.4
✔
python 3.5
✔
✔
python 3.6
✔
✔
python 3.7
✔
✔
✔
python 3.8
✔
✔
✔
python 3.9
✔
✔
✔
python 3.10
✔
✔
✔
python 3.11
✔
✔
✔
python 3.12
✔
✔
✔
>>> format( 15, 'x' )
'f'
>>> '%x' % 15
'f'