Learn

Conditional Statements

# Logical Operators

Logical operators are used to combine multiple boolean expressions and determine the overall truth or falsehood of the combined expression. They are particularly useful for making decisions based on multiple conditions.

There are three main logical operators: AND, OR, and NOT.

**AND Operator (**The AND operator returns true if both of its operand expressions are true. Otherwise, it returns false.`&&`

):**OR Operator (**The OR operator returns true if at least one of its operand expressions is true. If both expressions are false, it returns false.`||`

):**NOT Operator (**The NOT operator returns the opposite boolean value of its operand expression. If the expression is true, it returns false. If the expression is false, it returns true.`!`

):

You can also combine multiple logical operators to create more complex conditions.

Remember to use parentheses `()`

when combining logical operators to control the order of evaluation.

Now that we understand logical operators, we can use them within conditional statements to make more nuanced decisions in our code.

## Instructions

**1.**

Create a variable `result1`

and assign the value of `x`

less than or equal to `y`

using the `<=`

operator.

**2.**

Create a variable `result2`

and assign the value of `y`

greater than `x`

and `z`

using the `&&`

operator.

Sign up to start coding

Already have an account?

Sign In