0

what is 0o10?

a_int=10 b_int=3 c_int=2 print(0o10+c_int)

7th Dec 2016, 3:18 AM
Seng Thai
Seng Thai - avatar
2 Answers
+ 11
Starting a number with a zero marks it as octal in Python 2. This has been recognized as confusing, surprising and also inconsistent, as starting with 0x will mark it as hexadecimal. Therefore, in Python 3, starting with 0 is invalid, and you get octal by starting with 0o. You can also start with 0b to mark it as binary. >>> 10 10 >>> 0x10 16 >>> 0o10 8 >>> 0b10 2 >>> 010 File "<stdin>", line 1 010 ^ SyntaxError: invalid token 0x, 0o and 0b also works in Python 2.6 and Python 2.7.
7th Dec 2016, 3:33 AM
Hadi Akbarzadeh
Hadi Akbarzadeh - avatar
0
Thanks,sir
7th Dec 2016, 3:36 AM
Seng Thai
Seng Thai - avatar