CBSE Class 11 Computer Science Question 85 of 106

Python Fundamentals — Question 14

Back to all questions
14
Question

Question 14

Carefully look at the following code and its execution on Python shell. Why is the last assignment giving error ?

>>> a = 0o12
>>> print(a)
10
>>> b = 0o13
>>> c = 0o78
    File "<python-input-41-27fbe2fd265f>", line 1
    c = 0o78
         ^
SyntaxError : invalid syntax         
Answer

Due to the prefix 0o, the number is treated as an octal number by Python but digit 8 is invalid in Octal number system hence we are getting this error.