Idea 9of 23Builds onCode is exact steps in order
A condition is yes or no
What kind of question can code ask?
Today you'll discover
- what a condition is
- how to read the sign >
- why 20 > 20 is false
Think firstIF number > 20: a question with two answers
The question is: is the number greater than 20? What is the answer when the number is 20?
Decide first, then press Next. Read the question in the diamond, then follow the number down.
A flowchart: number goes in at the top, an orange diamond asks Is number > 20?, a yes path marked THEN to ADD 5 on the left and a no path marked ELSE to MULTIPLY BY 2 on the right, meeting at OUTPUT. 24 travels the yes path to 29; 12 travels the no path to 24. Along the bottom: 24 yes to 29, 12 no to 24, 20 no to 40 (ringed), 30 yes to 35. The last step asks about Is number < 10?
See the whole ideathe big idea and the key word, in one place
The big idea
A condition is a question with only two answers: yes (true) or no (false).
Compare them24 > 20 is true. 20 > 20 is false, because 20 equals 20. 12 > 20 is false.
Why only two answersA computer can only act on a clear yes or no, so every condition is either true or false.
Key words
- condition
- a yes-or-no question in code, such as number > 20, that is either true or false
- flowchart
- a drawing of code: a diamond for each question, with a path for yes and a path for no
Ready to use it?
- Say whether a condition is true or false for a number.