KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

In Python, what would be the condition to check if a value is not equal to 5?

  1. x =! 5
  2. x != 5
  3. x not= 5
  4. x == 5

Python Control Flow

1 Like

Answer

x != 5

Reason — In Python, the != operator is the not equal to comparison operator. It is used to check whether two values are not equal. Therefore, the correct condition to check if a value is not equal to 5 is x != 5.

Answered By

3 Likes


Related Questions