Learn
Logical Operators
Logical Operator: !

The not logical operator is denoted by !.

It reverses the bool outcome of the expression that immediately follows.

Here’s the truth table:

a !a
false true
true false

For instance:

  • ( !true ) returns false
  • ( !false ) returns true
  • ( !(10 < 11) ) returns false

Note: The keyword not can be used in the place of !.

Instructions

1.

Write the following if statement:

  • If the user is !logged_in, then print the phrase "Try again".
Folder Icon

Take this course for free

Already have an account?