Variables and Logic Gates in Programming
Computer Science
Year 9
10 questions
~20 mins
0 views0 downloads
About This Worksheet
This worksheet tests your understanding of variables and basic logic gates in programming. Answer the questions carefully and clearly.
Worksheet Preview
Full preview • 10 questions
Variables and Logic Gates in Programming
Subject: Computer ScienceGrade: Year 9
Name:
Date:
TeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizzTeachWhizz
Untitled Worksheet
Grade Year 9
A
Questions
This worksheet tests your understanding of variables and basic logic gates in programming. Answer the questions carefully and clearly.
Answer all questions in the spaces provided.
1.
Define a variable in programming and explain its purpose.
[4 marks]2.
Write a simple line of code in a programming language of your choice that assigns the value 10 to a variable named 'score'.
[3 marks]3.
Describe what happens when the following code is executed: 'x = 5; y = x + 3;'. What are the values of 'x' and 'y' afterwards?
[4 marks]4.
Complete the truth table for the AND logic gate with two inputs, A and B. Fill in the output column for all input combinations.
[6 marks]| A | B | Output |
|---|---|---|
| 0 | 0 | |
| 0 | 1 | |
| 1 | 0 | |
| 1 | 1 |
5.
Complete the truth table for the OR logic gate with two inputs, A and B. Fill in the output column for all input combinations.
[6 marks]| A | B | Output |
|---|---|---|
| 0 | 0 | |
| 0 | 1 | |
| 1 | 0 | |
| 1 | 1 |
6.
Complete the truth table for the NOT gate with a single input, A. Fill in the output for each input.
[4 marks]| A | Output |
|---|---|
| 0 | |
| 1 |
7.
Draw a logic circuit diagram that uses an AND gate and an OR gate to produce a specific output based on two inputs, A and B. Label the gates and inputs.
[8 marks]Drawing / Sketch space
8.
Explain the difference between a variable and a constant in programming.
[4 marks]9.
If variable 'a' has the value 7 and variable 'b' has the value 3, what is the result of the expression 'a - b'?
[3 marks]10.
Sketch a simple flowchart that shows how a variable might be used to store the result of a calculation in a program. Use large blank space for your drawing.
[8 marks]Drawing / Sketch space
Quick Actions
What is Remix?
Create a new worksheet based on this one. Change the grade level, topic, number of questions, or difficulty - then generate a fresh version.
- • Change grade level (Grade 6 → Grade 7)
- • Swap topics (Harry Potter → Macbeth)
- • Add more questions (10 → 15)
- • Adjust difficulty
Details
- Created
- 1/2/2026
- Updated
- 1/2/2026
- Type
- worksheet