Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This chapter is all about taking control of your code by making programs flow as you want. You’ll see how to make choices with the if statement, loop over and over with loops, and more.
The primary program flow statement that allows you to make choices is the if statement. With the if statement, you can test a condition and execute code depending on whether or not the statement is true. For example, say you have a variable named temperature, which is set to 72: