❓ Condition

3rd Grade 💻 Coding

A condition is a question whose answer is yes or no (true or false), and the program uses that answer to decide which instructions to carry out.

Free · US Letter · no sign-up
Google Classroom Save to Pinterest Email me

A condition is a decision point in a program: “Is the character touching the wall?”, “Is the password correct?”, “Is the score greater than 100?” If the answer is true, the program does one thing; if it’s false, it does something else — or does nothing and keeps going.

Without conditions, software would always do exactly the same thing. Conditions let it react to what’s happening: to the player, to the time of day, to what someone typed. Scratch has a mouth-shaped “if … then …” block, and Python and JavaScript use the word if.

For example

  • “If the character touches a coin, add a point” is a condition found in almost every game.
  • A smart thermostat checks: “If the room is warmer than 78°F (about 26°C), turn on the air conditioning.”
  • On a sign-up form: if the name box is empty, show “Please enter your name”; if it’s filled in, move on to the next step. That condition keeps the form in order.

📌 Remember: Condition = a yes-or-no question that splits the path.

Quick quiz

  1. What is a condition?

  2. What are the possible answers to a condition?

  3. Which word do you use to write a condition in Python?

🔎 Ask Thinkapedia another question