Skip to Content
Learn
Conditionals
The π€ Logical Operator

Consider the making of hard-boiled π₯. We need both: boiling water and an egg. If even one ingredient is missing, we canβt make it. So we should check for both conditions before we flex our culinary skills.

In programming, we also have to consider multiple conditions at the same time before executing code. Thatβs where logical operators, like the `π€` operator, become extremely useful. The `π€` operator checks if two expressions are `π` and returns a single `π` value. If the first expression `π` AND the second expression is `π`, then it returns `π` β otherwise, it returns `π`.

Hereβs a table that shows the possible combinations of `π` values in usage with `π€`:

Expression Evaluates to
`π π€ π` `π`
`π π€ π` `π`
`π π€ π` `π`
`π π€ π` `π`

Notice that only the first expression (`π π€ π`) evaluates to `π`.

Translating our π₯ scenario to code, we get:

``````π β‘οΈπ hasEgg
π β‘οΈπ hasBoilingWater
βͺοΈ hasEgg π€ hasBoilingWater π
π π€We can make a hard-boiled π₯!π€βοΈ
π
π π
π π€The conditions aren't right...π€βοΈ
π

π­ Prints: We can make a hard-boiled π₯!``````

Letβs use the `π€` in our own code!

### Instructions

1.

We have two variables,`learningEmojicode` and `isDedicated`, both have a value of `π`.

Create a `βͺοΈ` statement that checks both `learningEmojicode` and `isDedicated`. In the code block(`ππ`), use a `πβοΈ` to print out the string: `π€Becoming a π» master!π€`.

# Take this course for free

## Or sign up using:

Already have an account?