← Back to blog Python

Python If Statements & Conditions for Beginners

June 19, 2026

If statements let a program make decisions. In computer science this is called selection, and it appears all over the GCSE and A-Level specifications. This guide explains how conditions work in Python with examples you can run.

A simple if statement

age = int(input("Your age: "))
if age >= 18:
  print("You can vote")

Adding else

else runs when the condition is false:

if age >= 18:
  print("You can vote")
else:
  print("Too young")

Several options with elif

if mark >= 70:
  print("Pass with merit")
elif mark >= 50:
  print("Pass")
else:
  print("Fail")

Comparison operators

Combining conditions

Use and, or and not to build more complex tests:

if age >= 13 and age <= 19:
  print("You are a teenager")

Common mistakes

Try changing the values in these examples in our free online Python IDE to see how the output changes — it is the fastest way to understand selection.

Try these conditions yourself.

Run if/elif/else examples in our free Python IDE.

Open the Python IDE →

Practise selection with feedback

Solve auto-marked challenges on if statements.

Try the challenges →