If...Then

If...then is a way of thinking that allows us to make decisions based on Logic.

It can help us make decisions in mathematics, computer science and everyday life.

Here we explore the basics of using if...then logic, as well as how to use "and", "or" and "not".

Using If...Then

The basic structure of an if...then statement is simple:

If a condition is true, then something happens
Open umbrella

Example: If it is raining, then I will take an umbrella.

In that example, the condition (it is raining) triggers the decision (take an umbrella).

There are two parts:

And Or Not

We can combine conditions together using and, or and not.

It works like this:

And

We can use and when both conditions have to be true for the statement to be true.

Stylized icons representing rain and wind

Example: If it is raining and windy, then I will wear a raincoat.

If it is only raining or only windy then we don't make the decision. But if it is both rainy and windy we want that coat!

Example: If I am hungry and I have enough money, then I will buy lunch.

If we aren't hungry or don't have money we won't be buying lunch!

Or

Or is used when either condition (or both!) trigger the decision.

Rain icon or Snowflake icon then Open umbrella

Example: If it is raining or snowing, then I will take an umbrella.

In that example, either condition (it is raining or it is snowing) can be true for the decision to be true. A mix of rain and snow also works.

We can also have many conditions!

Example: If it is raining or snowing or cloudy, then I will take an umbrella.

The result (take an umbrella) will happen if any of those conditions are true.

And vs Or:

  • and: all the conditions must be true
  • or: at least one of the conditions is true (maybe more)

Not

We can also make the decision when a condition is not met:

Example: If it is not sunny, then I will take an umbrella.

"Not sunny" means the condition "sunny" is false. It could be cloudy, raining, snowing, or even nighttime!

Numbers

Numbers are often part of the decision:

Example: If you have 8 items or fewer, then you can use this checkout.

Example: If the time is 8:00 and it is a weekday, then you should be out the door heading for the bus stop.

Example: If you aren't in the top 20%, then you must do extra study.

Mathematics

In mathematics we often use this:

If (a condition is true), then (a conclusion must be true).

Example: Listing the possible values

If x > 10 and x is even, then x could be {12, 14, 16, ...}

Example: Solving with Conditions

If x + 3 = 10, then x must be 7.

Conditional

If...then is also called a conditional argument

Traffic lights with red, yellow, and green signals

Conclusion

If...then, and, or and not are powerful ways to make logical decisions.

By understanding the basics of this logic you can make better decisions in your everyday life.