From the course: Computer Science Principles: Programming
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Build compound conditional tests
From the course: Computer Science Principles: Programming
Build compound conditional tests
- Simple questions are easy to understand and program, but life is rarely simple. When you create conditional tests sometimes you need to ask multiple questions to get to the single true or false answer you need to proceed. In programming you can do exactly that with logical operators. If we have a single test, you will get a single true or false answer. This can be a literal value, a variable, an evaluation using equality operators or a function that returns a boolean value type. But if I have two tests, I need to find a way to get a single true or false answer. One possible question to ask is if A is true or if B is true, then it is true. This uses the or logical operator. It says that if either of the items are true, then the whole thing is true. With two tests there are four possible combinations. Three of which would evaluate as true, and one would be false. The only way this could be false is if both evaluations were false. The other possible question to ask is if A is true and…
Contents
-
-
-
-
-
(Locked)
Capture input from the user3m 31s
-
(Locked)
Manage different variable types2m 4s
-
(Locked)
Create conditional tests4m 39s
-
(Locked)
Build compound conditional tests4m 19s
-
(Locked)
Use while loops2m 11s
-
(Locked)
Use for loops3m 11s
-
(Locked)
Create arrays to store groups of values2m 28s
-
(Locked)
Use loops with arrays2m 5s
-
Changing arrays2m
-
(Locked)
-
-
-