What is the result of the expression not True in Python?
a) True
b) False
c) 1
d) None
Answer:
b) False
Explanation:
In Python, the not operator is a logical operator that inverts the truth value of its operand. If the operand is True, the not operator returns False, and if the operand is False, it returns True.
result = not True # result is False
The not operator is often used in conditional statements to reverse a condition, such as in situations where you want to execute a block of code only if a condition is not met.
Understanding logical operators like not is fundamental in writing clear and effective conditional logic in Python, allowing you to create more complex decision-making processes in your programs.