Class 7 (Grade 7) ยท Computer Science
Selection & Conditions: Class 7 Computer Science
How a program chooses between paths: conditions, IF and ELSE, comparison operators, AND, OR and NOT, nested selection, and how to trace and test a decision.
- Lesson
- 6 quizzes
- Worksheet PDF
A step-by-step lesson, 6 self-marking quizzes and a printable worksheet, all on Selection & Conditions for Class 7.
Selection & Conditions: the short answer
Every choice is built on a condition, a question that can only be answered true or false. Is the score above 10? is a condition. What is your score? is not, because its answer is a number.
Learn it: the lesson
Selection & Conditions8 steps ยท one idea at a time ยท quick check at the endStart the lesson โWhat the lesson covers8 steps ยท tap to see
1A program that can choose
Most programs do more than follow one fixed list of steps.
Learn this in the lesson โ2IF and IF ... ELSE
The simplest decision is IF.
Learn this in the lesson โ3Comparison operators
A condition usually compares two values.
Learn this in the lesson โ4ELSE IF chains
Sometimes there are more than two outcomes.
Learn this in the lesson โ5Joining conditions: AND, OR, NOT
One condition is sometimes not enough.
Learn this in the lesson โ6Nested selection
A decision can sit inside another decision.
Learn this in the lesson โ7The decision diamond in a flowchart
In a flowchart, a decision is drawn as a diamond.
Learn this in the lesson โ8Tracing a short program
To trace a program, you act as the computer: write down each value and decide each condition in turn.
Learn this in the lesson โ- Quick check: see what you remember
Selection & Conditions: Class 7 Computer Science notes
A program that can choose
Most programs do more than follow one fixed list of steps. They look at a value and decide. A phone dims its screen when the room is dark. A game ends when your lives reach 0. This is called selection: the program selects which steps to run.
Every choice is built on a condition, a question that can only be answered true or false. Is the score above 10? is a condition. What is your score? is not, because its answer is a number.
IF and IF ... ELSE
The simplest decision is IF. The steps inside it run only when the condition is true. If it is false, the program skips them.
INPUT temperatureIF temperature > 30 THEN OUTPUT "Wear a hat"ENDIF
Add ELSE when there is something to do in the other case. Exactly one of the two paths runs, never both and never neither.
INPUT ageIF age >= 12 THEN OUTPUT "Teen ticket"ELSE OUTPUT "Child ticket"ENDIF
The indented lines show which steps belong to which path. ENDIF closes the decision.
Comparison operators
A condition usually compares two values. The comparison gives true or false.
Key facts
- A condition is a question that is true or false. Comparisons use =, <>, <, >, <= and >=.
- IF runs steps when true; ELSE covers the other case. An ELSE IF chain runs the first true branch only.
- AND needs both, OR needs one, NOT flips the answer. Decisions can be nested.
- A flowchart shows a decision as a diamond with Yes and No arrows.
- Trace by hand and test the boundaries. Check the operator, the order of tests and AND against OR.
Selection & Conditions MCQs with answers
Tap an answer to check it.
What is selection in a program?
Answer: A. The program chooses which instructions to run, based on a condition Selection uses a condition, such as IF, to decide which block of instructions runs and which is skipped.
Which keyword ends an IF statement in pseudocode?
Answer: B. ENDIF An IF statement in pseudocode is closed with ENDIF; ENDWHILE closes a WHILE loop instead.
Why would a programmer use ELSE IF?
Answer: D. To test another condition when the first one is false ELSE IF adds a further test that is only checked when the earlier condition was false.
In an ELSE IF chain, one condition is found to be true. What happens to the conditions after it?
Answer: A. They are skipped Once one condition in the chain is true, its code runs and the remaining tests are skipped.
More questions in the 6 quizzes below โ ยท All Class 7 Computer Science MCQs with answers โ
Practise real quizzes on this topic: 6 quizzes
Each quiz marks itself the moment it is finished and explains every answer. Start easy and work up.
- EasySelection & Conditions: Easy 18 questions๐ Free account
- EasySelection & Conditions: Easy 28 questions๐ Free account
- MediumSelection & Conditions: Medium 18 questions๐ Free account
- MediumSelection & Conditions: Medium 28 questions๐ Free account
- ChallengeSelection & Conditions: Applied 18 questions๐ Free account
- ChallengeSelection & Conditions: Applied 28 questions๐ Free account
Print it: the worksheet Save to Pinterest
๐จ๏ธSelection & ConditionsHow a program decides with IF, ELSE and ELSE IF. Pupils judge true or false conditions with comparison operators, AND, OR and NOT, trace short programs, name the flowchart decision shape and find and fix two logic errors. Fifteen questions.See the worksheet โโฌ Download free PDFFree sample copy with a light QuizByt mark. A free account gives you more.
All Class 7 Computer Science topics
- Number Systems & Data Representation
- MS Excel: Formulas & Charts
- Introduction to Programming
- Internet Safety & Cyber Ethics
- Computer Networks & the Web
- Selection & Conditions
- Databases & Queries
- Web Design Basics
- Introduction to Artificial Intelligence
- Flowcharts and Pseudocode
- Inside a Computer: CPU, Memory and Storage
- Logic Gates: AND, OR and NOT