From the course: Computer Science Principles: Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create conditional tests

Create conditional tests

From the course: Computer Science Principles: Programming

Start my 1-month free trial

Create conditional tests

- Computers process in binary, ones and zeros, true and false. In programming, you need to think in binary as well. When you create code that does different things based on data, you are creating a conditional. You create the condition, or the test, and you find out if the test is true or false. If it is true, you do one thing. If it is false, you do another. The idea of true and false is the basic building block of computers, so in programming there is a special data type designed exactly for this, a Boolean value. A Boolean variable can be assigned one of two possible values, true or false. I can also create a function that returns a Boolean value type as well. I can also create an evaluation, but I need to use a different set of operators to do the evaluation. Regular math operators, like addition and multiplication, don't give me a true or false answer. Instead, I need to use equality operators. In programming, there are six to choose from. I can ask if one value is equal to…

Contents