Compound Statements

Learn about compound statements in detail.

We'll cover the following

Compound statements

As we learned in the previous lesson, a compound statement is a statement that spans several lines. These compound statements are made up of one or more normal one-line statements. They can also consist of other compound statements, which we’ll learn later on. For example, in our previous application that turns on the outdoor lights, we have some conditions that must be met before we do something. One condition is that we only turn on the lights if the current time is after sunset. The logic can be visualized in a flowchart:

Get hands-on with 1200+ tech skills courses.