Programming Fundamentals Practice Questions

GCSE · GCSE Computer Science · 149 free MCQs with instant results and detailed explanations.

149
Total
47
Easy
74
Medium
28
Hard

Start Practicing Programming Fundamentals

Take a timed quiz or customize your practice session

Quick Quiz (10 Qs) → Mock Test (25 Qs) ⚙ Customize

Sample Questions from Programming Fundamentals

Here are 10 sample questions. Start a quiz to get randomized questions with scoring.

Q1
Easy
What is the primary purpose of a variable in programming?
A. To store data values
B. To create loops
C. To define functions
D. To handle errors
Show Answer & Explanation
Correct Answer: A
A variable is used to store data values that can be manipulated throughout the program. It allows programmers to refer to stored values using names.
Q2
Easy
Which of the following is a valid way to declare a variable in Python?
A. var age = 20
B. int age = 20
C. age = 20
D. declare age = 20
Show Answer & Explanation
Correct Answer: C
In Python, variables are declared by simply assigning a value to a name. 'age = 20' correctly assigns the value 20 to the variable 'age'.
Q3
Easy
What will the following pseudocode output? ``` SET x TO 5 SET y TO 10 SET z TO x + y PRINT z ```
A. 15
B. 5
C. 10
D. 20
Show Answer & Explanation
Correct Answer: A
The pseudocode adds the values of x (5) and y (10) and stores the result in z. The final output will be the value of z, which is 15.
Q4
Medium
What is the primary purpose of using variables in programming?
A. To store data values that can change during program execution.
B. To write comments in the code.
C. To create graphical user interfaces.
D. To define the programming language syntax.
Show Answer & Explanation
Correct Answer: A
Variables are used to store data values that can be modified and retrieved during program execution, making them essential for dynamic programming.
Q5
Medium
In Python, which of the following will correctly create a list with the values 1, 2, and 3?
A. [1, 2, 3]
B. {1, 2, 3}
C. (1, 2, 3)
D. <1, 2, 3>
Show Answer & Explanation
Correct Answer: A
In Python, lists are defined using square brackets. Therefore, the correct way to create a list with values 1, 2, and 3 is [1, 2, 3].
Q6
Medium
Which of the following is an example of a conditional statement in programming?
A. if (x > 5) { doSomething(); }
B. for (i = 0; i < 10; i++) { doSomething(); }
C. while (true) { doSomething(); }
D. function doSomething() { return; }
Show Answer & Explanation
Correct Answer: A
An 'if' statement is a type of conditional statement that executes a block of code only if a specified condition is true, making option A the correct answer.
Q7
Medium
What will be the output of the following Python code snippet: print(2 ** 3)?
A. 6
B. 8
C. 9
D. None of the above
Show Answer & Explanation
Correct Answer: B
The expression 2 ** 3 in Python calculates 2 raised to the power of 3, which equals 8. Hence, the correct output is 8.
Q8
Hard
Which of the following best describes the purpose of a 'while loop' in programming?
A. To execute a block of code a specific number of times.
B. To repeat a block of code as long as a specified condition is true.
C. To sort an array of values in ascending order.
D. To define a function that can be called at any point.
Show Answer & Explanation
Correct Answer: B
'While loops' continue to execute a block of code as long as a specified condition remains true. This makes them ideal for situations where the number of iterations is not known beforehand.
Q9
Hard
In a Python program, what will be the output of the following code snippet? ```python x = 5 while x > 0: print(x) x -= 2 ```
A. 5 3 1
B. 5 3 1 0
C. 5 4 3 2 1
D. 5 3 2 0
Show Answer & Explanation
Correct Answer: A
The loop starts at x = 5 and decrements x by 2 with each iteration. It prints 5, then 3, and finally 1 before x becomes 0, which stops the loop.
Q10
Hard
In a programming language, which of the following statements correctly describes the concept of a 'function'?
A. A function is a piece of code that performs a specific task and can return a value.
B. A function is a collection of variables that holds data for a program.
C. A function is a way to store sequences of character data.
D. A function is a diagram that illustrates the flow of a program.
Show Answer & Explanation
Correct Answer: A
Option A is correct because a function is defined to perform particular operations and may return a value after execution, making it a fundamental programming construct.

Showing 10 of 149 questions. Start a quiz to practice all questions with scoring and timer.

Practice All 149 Questions →

Programming Fundamentals โ€” GCSE GCSE Computer Science Practice Questions Online

This page contains 149 practice MCQs for the chapter Programming Fundamentals in GCSE GCSE Computer Science. The questions are organized by difficulty โ€” 47 easy, 74 medium, 28 hard โ€” so you can choose the right level for your preparation.

Every question includes a detailed explanation to help you understand the concept, not just memorize answers. Take a timed quiz to simulate exam conditions, or practice at your own pace with no time limit.