Fig. 1 shows a smart-home program that decides whether a window should be closed. The window closes if rain is detected, or if the outside temperature is be...

Assessment: Computer Science 9210 | Paper 1 Mock 01 | Programming (on-screen) Subject: Computer Science - 9210

Question 1 Report

Fig. 1 shows a smart-home program that decides whether a window should be closed. The window closes if rain is detected, or if the outside temperature is below 2 degrees C and the house is empty. The temperature comparison creates veryCold. A resident is at home while the temperature is below 2 degrees C and no rain is detected. The programmer wants to predict the command before running a test, because closing the window unnecessarily would be inconvenient.

closeWindow = rainDetected OR(veryCold AND NOT houseOccupied)

(a) Explain why houseOccupied is preceded by NOT. [2]
(b) When rainDetected is False, veryCold is True and houseOccupied is True, state the value of closeWindow. [1]
(c) When rainDetected is True, state the value of closeWindow. [1]



Fig. 1 shows an electronic scoreboard program for a wheelchair basketball game. At the end of a turn, the program awards a bonus if the player scored at least 10 points and did not commit a foul. The two comparison statements are evaluated before the IF statement runs. A trainee has placed brackets around the NOT operation. The referee wants to know whether the command works correctly when a player earns 12 points but commits a foul during the same turn.

IF (points >= 10) AND (NOT foul) THENbonus = True

(a) Explain why the second condition uses NOT foul. [2]
(b) When points >= 10 is True and foul is True, state whether the bonus is awarded. [1]
(c) When the player scores 8 points and does not foul, state whether the bonus is awarded. [1]

Answer Details

Smart-home condition

  1. (a) The cold-weather rule applies only when the house is empty. [1] Therefore, if houseOccupied is True, NOT houseOccupied is False, preventing the cold-and-empty part of the condition from closing the window. [1]
  2. (b) With no rain, very cold weather, and an occupied house: NOT houseOccupied is False, so True AND False is False; False OR False gives False. [1]
  3. (c) If rainDetected is True, the OR condition is True regardless of the other values. Therefore closeWindow is True. [1]

Basketball-bonus condition

  1. (a) A foul prevents the bonus. [1] NOT foul is True only when foul is False, so it correctly represents the requirement of no foul. [1]
  2. (b) If the points condition is True but foul is True, then NOT foul is False. True AND False is False, so the bonus is not awarded. [1]
  3. (c) A score of 8 makes points >= 10 False. Even without a foul, False AND True is False, so the bonus is not awarded. [1]

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning