QuestionQ42

VerifiedPython Basics

What is the output of this line of code entered in a Python interactive session?

>>> print(~100)  
Explanation

Python’s unary bitwise-inversion operator follows the identity ~n == -(n + 1) for integers. Thus, ~100 evaluates to -101, and print outputs that value.

Community Discussion

No comments yet. Be the first to start the discussion!