Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

If-statements

If-statements are the only form of selection in Python.

If statements

If statements

  • Conditions can be tested using the if statement. For example:
    • if (x > 50):
  • Any code written in an indented block after this line will be executed if the condition is true.
Else statements

Else statements

  • We can also add an else statement to the end, for example:
    • else:
  • This will only execute the following indented block if the condition was false.
Elif statements

Elif statements

  • Elif statements can be added between if and else blocks.
  • They will execute if the condition before it was false, and the condition following it is true.
Jump to other topics
1

Computational Thinking & Algorithms

2

Programming

3

Hardware & Software

4

Data

5

The Internet

6

Online Safety & Security

Practice questions on Selection

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
Answer all questions on Selection

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium