You use an if statement if you only want to do something sometimes. For example,

  • If it’s early, make coffee.
  • If you’re under four feet tall, you can’t ride the rollercoaster.
  • If you’re good, Santa Claus brings you presents, otherwise you get coal

The fancy name for these kinds of statements are conditionals and flow control.