Difference between revisions of "Python:Numbers"
Jump to navigation
Jump to search
(Created page with "NOTE: Numbers starting with 0 are interpreted as octal number. Look at this: <syntaxhighlight lang=python> >>> a = 0123 >>> print(a) 83 >>> type(a) <type 'int'> </syntaxhighl...") |
(No difference)
|
Latest revision as of 15:43, 27 January 2022
NOTE: Numbers starting with 0 are interpreted as octal number.
Look at this:
>>> a = 0123
>>> print(a)
83
>>> type(a)
<type 'int'>
- int(x)
- Convert x into an integer
- hex(x)
- Convert x into an hexadecimal number 0x....
- oct(x)
- Convert x into an octal number 0....
See Python:Strings#Advanced for conversions by format.