Q. 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

0o78

Syntax Error: invalid syntax


Answer =


Due 0o this is an Octal number but the Octal number contains only numbers from 0-7 but there is 8 so it will give an error.

It may be :-

c = 0o77

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. It is octal (starting with 0o)not hexadecimal
    Octal does not have value 8, so it is error

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post