3 ответов
+ 7
~x returns the bitwise complement of x, i.e. the number you get by switching each 1 for a 0 and each 0 for a 1. This is the same as -x - 1.
+ 4
It's the bitwise Inversion (two's compliment) operator.
https://docs.python.org/3/library/operator.html
https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types
https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations
https://docs.python.org/3.6/reference/datamodel.html#object.__invert__
https://docs.python.org/3.6/genindex-Symbols.html
https://docs.python.org/3.6/reference/simple_stmts.html#index-14
+ 4
The quiz in question asks you to check off which of a list of four items are valid Python operators. If you check off ~, you get it wrong. I have reported it as a wrong answer.