MCQ Answer

What does ~~~~~~5 evaluate to?

What does ~~~~~~5 evaluate to?

~~~~~~5 का मूल्यांकन किससे होता है?
Topic : Operators Expressions and Python Statements

A. +5

B. -11

C. +11

D. -5




Correct Answer is :

A. +5



Explanation
The expression ~~~~~~5 evaluates to 5.

In Python, the ~ operator is the bitwise NOT operator, which inverts all the bits of its operand. When applied to an integer n, it computes -(n + 1).

Here's a step-by-step breakdown of the evaluation:

  • ~5 evaluates to -(5 + 1), which is -6.
  • ~~5 evaluates to ~~5. Since ~5 is -6, applying ~ again: ~-6 evaluates to -(-6 + 1), which is 5.
This pattern continues: each pair of ~ operators cancel each other out. Since there are an even number of ~ operators in ~~~~~~5 (six in total), they all cancel out, leaving the original number, which is 5.
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad