0

Why it’s result is 10

a=0o12 Print(a) 10

22nd Oct 2018, 3:42 AM
ishu Shrivas
ishu Shrivas - avatar
5 Respostas
+ 7
Octal literals, numbers in octal format are prefixed with 0o. https://www.python.org/dev/peps/pep-3127/
22nd Oct 2018, 3:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
ishu Shrivas Octal literals, are numbers of base 8. 0o12 = (8^1)*1 + (8^0)*2 = 10 0o78 results in syntax error because it is impossible for the number 8 to appear anywhere within the expression of an octal literal. Please refer to this table: https://www.rapidtables.com/math/number/Numeral_system.html
22nd Oct 2018, 4:07 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
okk now it is clear thank u very much Hatsy Rei
22nd Oct 2018, 4:09 AM
ishu Shrivas
ishu Shrivas - avatar
0
i didn’t understand Hatsy Rei please clear it easily ...
22nd Oct 2018, 3:54 AM
ishu Shrivas
ishu Shrivas - avatar
0
& why there is error in the following codes c=0o78 print(c) syntax error
22nd Oct 2018, 3:57 AM
ishu Shrivas
ishu Shrivas - avatar