DEV Community

loading...
Cover image for Logical Operators in python

Logical Operators in python

Aswin Barath
Budding Software Engineer | Web Developer | Blogger
Updated on ・1 min read

Logical operators are used to combining more than two conditional statements.

These operators are very useful for writing logical conditions in control flow statements of a programming language.

Let's code them one by one.

and operator

  • and operator return the boolean value True only if both statements are true. Alt Text Output:
True
Enter fullscreen mode Exit fullscreen mode

or operator

  • or operator returns the boolean value True if any statement is true. Alt Text Output:
True
Enter fullscreen mode Exit fullscreen mode

not operator

  • not-operator acts as a unary operator which returns the boolean value True the statement is true and vice versa. Alt Text Output:
False
Enter fullscreen mode Exit fullscreen mode

Code along and have fun ;)

Discussion (0)

Forem Open with the Forem app