- 1
Boolean expressions and logical operators
Does negation operator exist in Python? For example, in C++, a token or literal can be negated using '!' before it, like so: x=1; cout<<!x; Output: 0
5 Respostas
- 2
No, I'm talking about the logical negation. Not the arithmetic negation. Take another look at my sample code.
+ 5
Yes instead of ! not is used
eg
X=1
X= not 1
print(int(X))
This will result in 0
+ 1
Yes why not you may directly use negative symbol for that purpose.
Eg
X=1
X=-X
Now X will be equal to -1
+ 1
Megha Suresh you should set the better answer mark on the answer wich has been the most helpful/informative... not to yours or one not relevant ^^
- 1
Thank you very much. 😊