Chapter 9
Helping with Logic Operations
IN THIS CHAPTER
Understanding logic operations
Using conditionals
Putting multiple logic operations together
Coding a rock, paper, scissors game
Logic is the heart of programming. A computer program is essentially a giant set of logic statements, or rules, that execute in order. Similar to any decision-based field — law, forensic science, football, driving — programming enumerates rules that are put together logically. As the program executes, different subsets of rules are accessed, testing conditions and producing decisions, or outcomes. Outcomes then lead to the execution of other subsets of rules within the program, and so on.
This chapter guides you in helping your young coder master the application of logic in coding. Specifically, it helps you coach him in writing conditionals, also called if-then commands, beginning with easy ones. You also use and, not, and or commands to construct intended meaning in a conditional. Combining several logic operations together allows your coder to build up to increasingly more complex commands. By the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access