£199.99 £139.99 for one year of Unlimited learning. Offer ends on 14 November 2022 at 23:59 (UTC). T&Cs apply

Find out more
What are conditions?
Skip main navigation

What are conditions?

A condition is a statement that can be either true or false, and programmers can use conditions to trigger actions. Read more about them here.

Conditions are a key part of programming, but are also something that you probably use every day without thinking about it. A condition is a statement that can be either true or false, and programmers can use conditions to trigger actions.

Think about the number of actions you’ve taken today based on whether a particular condition was met or not. You probably got out of bed this morning, but only when it reached a certain time. You probably ate something, but only when you felt hungry. Each time, you acted based on whether a particular condition was met or not — you used a condition to trigger when something happened.

You can think of conditions in terms of a statement which can be true or false, or in terms of a question that you can answer with a yes or no:

True or false statement Yes or no question
It is past 6:30am. Is it past 6:30am?
I am hungry. Am I hungry?

Of course, there are many questions in everyday life which do not have a yes or no answer but still help you to make decisions and take actions, such as:

  • What chocolate bar would I like?
  • What’s my favourite colour?
  • What’s the weather today?

However, conditions don’t work that way; conditions must be phrased as a question with just two options, yes or no. You need to make sure that you write an appropriate condition (or several) in your program, otherwise it won’t work.

A robot being asked the question “What’s the weather today?” and giving an error.

So instead of asking “What’s the weather today?” you could ask yes or no questions (or make true or false statements) to help you decide what to wear instead:

  • Is it sunny?
  • Is it raining?

An animation of a robot by a window. It is raining outside. The condition "Is it sunny?" appears, and the robot responds "FALSE". The condition "Is it raining?" appears. The robot responds "TRUE" and puts up an umbrella.

Using comparisons in conditions

You can also create conditions that compare two things, such as asking if one thing is greater than (>) or less than (<) another. Instead of asking “Is it hot today?” — the answer to which is subjective — you might instead ask “Is today’s temperature greater than (>) 25°C?”


In the comments section, share more examples of conditions that you might consider in everyday life.

This article is from the free online

Introduction to Programming with Scratch

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education