1.

What does ~~~~~~5 evaluate to?(a) +5(b) -11(c) +11(d) -5I had been asked this question by my school principal while I was bunking the class.I need to ask this question from Numeric Types topic in division Variable Names, Operators, Data Types & Numeric Types of Python

Answer»

The correct answer is (a) +5

Easiest EXPLANATION - ~x is equivalent to -(x+1).

~~x = – (-(x+1) + 1) = (x+1) – 1 = x

~~x is equivalent to x

Extrapolating further ~~~~~~x would be same as x in the FINAL result.

In the question, x value is GIVEN as 5 and “~” is repeated 6 TIMES. So, the correct answer for “~~~~~~5” is 5.



Discussion

No Comment Found

Related InterviewSolutions