You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jolon Faichney edited this page Feb 17, 2017
·
6 revisions
Last week we introduced the three programming concepts of sequence, selection, and iteration. We have introduced sequence and iteration, but we haven't yet covered selection.
Selection is a computer's ability to make decisions. It is the foundation of artificial intelligence. Sequence and iteration make computers great machines for automating tasks, but it is selection that makes them smart.
Selection is deciding whether to execute a portion of code or not. When we introduced syntax the example was to go to the store and pick up some milk. Selection would involve whether we should buy some milk. For example, we might buy some milk if we have run out, or if the current milk is beyond it's expiry, or if we are planning a large gathering.
The if statement
Most programming languages implement selection with the if statement.