These worksheets are free forever. Want lessons that adapt to your child as they learn, plus progress tracking? Try Ignition Learning free.

Sign up free

Ignition Learning — Activity Sheet

Variables & conditionals

Technologies · Year 9

Name: ______________________Date: ____________

A variable stores a piece of data a program can use and change, like a player's score or a username. A conditional statement makes a program branch based on a condition — "if" something is true, do one thing; "else", do another. Combining variables and conditionals lets programs make decisions and react differently depending on changing data.

Example

A simple game might store score in a variable, starting at 0. When the player earns points, score increases. A conditional checks: "if score >= 100, show 'You win!'; else, keep playing" — the program's behaviour changes based on the variable's current value.

Key terms

Variable:
A named piece of data a program can store and change.
Conditional:
A statement that makes code run only if a condition is true.
Boolean:
A data type with only two possible values: true or false.

Questions

  1. 1. A variable stores:

    • A piece of data a program can use and change
    • A fixed, unchangeable value only
    • A type of hardware
    • A password only
  2. 2. A conditional statement makes a program:

    • Branch based on a condition
    • Always run the same way
    • Stop working entirely
    • Delete all variables
  3. 3. An "if" statement runs code:

    • Only if a condition is true
    • Always, regardless of conditions
    • Never
    • Only if a condition is false
  4. 4. A boolean value can be:

    • True or false
    • Any number
    • Any word
    • A colour
  5. 5. In "if score >= 100, show 'You win!'", score is a:

    • Variable
    • Conditional keyword
    • Boolean value directly
    • A password
  6. 6. An "else" statement runs when the "if" condition is:

    • False
    • True
    • Always ignored
    • Undefined only
  7. 7. A variable's value can:

    • Change while a program runs
    • Never change once set
    • Only be a boolean
    • Only be set by the computer's hardware
  8. 8. If score = 50 and the condition is "if score >= 100", the condition is:

    • False
    • True
    • Undefined
    • A syntax error
  9. 9. If age = 15 and the condition is "if age >= 13", the condition is:

    • True
    • False
    • Undefined
    • A syntax error
  10. 10. A game checks "if lives == 0, show Game Over". This is an example of:

    • Using a variable in a conditional
    • A variable with no conditional
    • A conditional with no variable
    • Neither a variable nor conditional
  11. 11. Why are variables useful in programs?

    • They let programs store and update changing information
    • They make programs run slower on purpose
    • They remove the need for any logic
    • They only work with numbers, never text
  12. 12. An "else if" (or "elif") statement is used when you need to:

    • Check multiple different conditions in sequence
    • Only ever check one condition
    • Avoid using variables entirely
    • Replace all variables with booleans
  13. 13. A traffic light program checks "if light == red, stop". Here, "red" represents:

    • A specific value the variable "light" could hold
    • A boolean only
    • A conditional keyword
    • A type of hardware
  14. 14. Which of these is a valid boolean condition?

    • age > 18
    • age
    • The word "hello"
    • A random colour
  15. 15. A weather app uses a variable temperature and shows "Wear a coat" if temperature < 10, otherwise "No coat needed". If temperature = 8, what is shown?

    • "Wear a coat"
    • "No coat needed"
    • Nothing at all
    • An error message
  16. 16. A login system checks "if username == stored_username AND password == stored_password, allow access". This combines a conditional with:

    • Multiple variables and a logical AND
    • No variables at all
    • Only one variable and no logic
    • A single boolean with no comparison
  17. 17. A program has: score = 0; score = score + 10; score = score + 5. What is the final value of score?

    • 15
    • 10
    • 5
    • 0
  18. 18. Why might a programmer use a variable instead of hardcoding a fixed number directly into many places in a program?

    • Changing the variable once updates it everywhere it's used, avoiding repeated manual edits
    • Variables always make programs run slower
    • Hardcoded numbers are always better practice
    • There is no difference between the two approaches
  19. 19. A quiz app tracks correct_answers as a variable. After 3 correct answers out of 5 questions, which conditional would correctly show "Great job!" only for scores of 3 or more?

    • if correct_answers >= 3, show "Great job!"
    • if correct_answers == 5, show "Great job!" only
    • if correct_answers < 3, show "Great job!"
    • A conditional cannot check this
  20. 20. Nested conditionals (an "if" inside another "if") are useful when:

    • A decision depends on more than one condition being checked in sequence
    • Only one condition will ever exist in any program
    • Nesting conditionals is always forbidden
    • Variables are not allowed inside conditionals
  21. 21. A loop that repeats "while score < 100" combines a conditional check with:

    • Repetition, continuing only while the condition stays true
    • A single one-time check with no repetition
    • No variable at all
    • A boolean that never changes

Answer key (parent copy)

  1. 1. A piece of data a program can use and change
  2. 2. Branch based on a condition
  3. 3. Only if a condition is true
  4. 4. True or false
  5. 5. Variable
  6. 6. False
  7. 7. Change while a program runs
  8. 8. False
  9. 9. True
  10. 10. Using a variable in a conditional
  11. 11. They let programs store and update changing information
  12. 12. Check multiple different conditions in sequence
  13. 13. A specific value the variable "light" could hold
  14. 14. age > 18
  15. 15. "Wear a coat"
  16. 16. Multiple variables and a logical AND
  17. 17. 15
  18. 18. Changing the variable once updates it everywhere it's used, avoiding repeated manual edits
  19. 19. if correct_answers >= 3, show "Great job!"
  20. 20. A decision depends on more than one condition being checked in sequence
  21. 21. Repetition, continuing only while the condition stays true