WorksheetsKS4 Programming - mmd
Total questions: 81
Worksheet time: 41mins
Which data type is used to store whole numbers only?
Real
Integer
Boolean
String
What is the typical amount of memory taken up by a Boolean data type?
1 byte
2 bytes
4 bytes
1 bit
Which function is used to convert a string to an integer in programming?
float()
bool()
int()
str()
What is the result of the expression bool(1) in programming?
0
False
True
1
Which data type is used to represent text, a collection of characters?
Integer
Real
String
Character
What is the ASCII number for the character 'b'?
97
98
99
100
Which data type should be used to store a person's height in meters?
Integer
Real
Boolean
String
What is the result of the expression 4 * 8 using the multiplication operator?
12
32
16
24
Which operator is used to raise a number to a power?
+
/
^
MOD
What does the DIV operator return?
The remainder of a division
The whole number part of a division
The sum of two numbers
The product of two numbers
Which rule should computers follow when using operators to ensure correct order of operations?
PEMDAS
BODMAS
BEDMAS
BOMDAS
What is the purpose of the assignment operator "=" in programming?
To compare two values
To add two numbers
To assign values to constants or variables
To divide two numbers
Which comparison operator checks if two values are not equal?
==
<>
>
<=
What is a constant in programming?
A value that can change during program execution
A value that remains the same throughout program execution
A variable that stores temporary data
A function that performs calculations
What is the purpose of declaring variables with data types?
To make the program run faster
To specify the kind of data a variable can hold
To increase the size of the program
To make the program more complex
Why might you assign the values 5 and 2 to constants in a program?
To allow them to change during program execution
To make the program more difficult to understand
To ensure they remain unchanged during program execution
To increase the number of variables in the program
What is the naming convention for constants and variables mentioned in the document?
Upper case for the first letter, followed by numbers
Lower case for the first letter, followed by a mixture of letters, numbers, and underscores
All upper case letters
All lower case letters
What is the purpose of using double or single quotation marks in programming strings?
To denote a comment
To start a loop
To define a string
To declare a variable
What does the '+' operator do when used with strings?
Subtracts strings
Multiplies strings
Concatenates strings
Divides strings
What is the starting index number for characters in a string?
1
0
2
10
Which function changes all characters in a string to uppercase?
x.lower
x.length
x.upper
x.subString
How do you extract the first three characters from a string variable named 'town'?
town.subString(0, 3).upper
town.subString(3, 0).upper
town.subString(0, 3).lower
town.subString(3, 0).lower
What is the effect of the x.length function on the string x = "Hello"?
Returns 5
Returns 4
Returns 6
Returns 0
What is the main purpose of an IF statement in programming?
To repeat a block of code multiple times
To check if a condition is true or false
To store data in a variable
To define a function
What should you do if there is nothing for the program to do when the condition is false in an IF statement?
Include an 'else' part
Leave out the 'else' part
Add a 'while' loop
Use a 'switch' statement
What is a nested IF statement used for?
To repeat a block of code
To check more conditions once a previous condition is true
To store multiple values
To define a new function
How are IF-ELSEIF statements different from nested IF statements?
They check more conditions if the previous condition is true
They check more conditions if the previous condition is false
They are used to repeat code
They store data in arrays
Flow diagram showing IF-THEN-ELSE structure
A flowchart with decision nodes and branches
A sequence of steps without any decision points
A diagram showing only linear steps
A chart with only start and end points
What is the primary purpose of SWITCH-CASE statements in programming?
To check if a statement is true or false.
To perform different actions for different values of the same variable.
To repeat a block of code a fixed number of times.
To check multiple conditions at once.
What is a drawback of SWITCH-CASE statements compared to IF-ELSEIF statements?
They are more complex to maintain.
They can only check the value of one variable.
They require more memory.
They cannot be used in loops.
In the context of FOR loops, what does the 'step count' refer to?
The number of times the loop will execute.
The initial value of the loop.
The increment by which the loop variable is increased each time.
The final value of the loop.
How can the number of times a FOR loop repeats be set?
By using a SWITCH-CASE statement.
By setting the program to run indefinitely.
By defining the loop with an initial value, end value, and step count.
By using a default case.
Diagram illustrating the flow of a SWITCH-CASE statement used to count votes in an election.
A flowchart showing the decision-making process for counting votes using SWITCH-CASE.
A diagram depicting the use of IF-ELSE statements in vote counting.
An illustration of a FOR loop used in the election vote counting process.
A diagram showing the use of a WHILE loop in counting votes.
Which type of loop is controlled by a condition at the end of the loop and always runs the code inside at least once?
WHILE loop
FOR loop
DO UNTIL loop
IF statement
In a WHILE loop, when does the loop stop executing?
When the condition is true
When the condition is false
After a fixed number of iterations
When the loop counter is zero
What happens if the condition in a DO WHILE loop is always true?
The loop runs once
The loop never runs
The loop runs infinitely
The loop runs twice
Which loop checks the condition at the start of the loop?
DO UNTIL loop
WHILE loop
FOR loop
SWITCH statement
Which Boolean operators are essential for working with Boolean values?
ADD, SUBTRACT, MULTIPLY
AND, OR, NOT
PLUS, MINUS, DIVIDE
IF, ELSE, SWITCH
In Boolean expressions, which order should operations be carried out?
OR, AND, NOT
NOT, OR, AND
Brackets, NOT, AND, OR
AND, OR, NOT, Brackets
What is the purpose of using brackets in Boolean expressions?
To increase the speed of computation
To make the expression look complex
To indicate which part to do first
To eliminate the need for NOT operator
In a computer game, a character's status depends on which three variables?
Speed, strength, intelligence
Hunger, hydration, comfort
Health, mana, stamina
Agility, power, defense
What is an array in programming?
A single data value
A collection of data values under one name
A type of loop
A function for sorting data
What is each piece of data in an array called?
Node
Element
Variable
Function
How are positions in an array numbered?
Starting at 1
Starting at 0
Starting at 2
Starting at -1
What is the size of the array 'rowers' in the example?
3
4
5
6
What happens when you reassign an array position to a different data value?
The array size increases
The original value is replaced
The array becomes a list
The array is deleted
What is a two-dimensional array often compared to?
A list of lists
A single list
A string of characters
A single number
How is the position of an element in a two-dimensional array usually written?
What does the code `scores[1, 3]` return in the given example?
12
14
15
13
What is the purpose of the `FOR` loop in the algorithm to count the total score of any given pupil?
To iterate over each pupil
To iterate over each test
To calculate the average score
To print the total score
What is the pass mark for every test in the example provided?
7
8
9
10
What is the first step before you can do anything with a file in programming?
Close it
Delete it
Open it
Rename it
Which command is used to read data from a file into your program?
writeLine()
readLine()
openWrite()
close()
What happens if you forget to close a file after reading or writing?
The file will be deleted
The file can remain locked
The file will be duplicated
The file will be encrypted
What does the endOfFile() command return when the 'cursor' is at the end of the file?
FALSE
0
TRUE
NULL
What is the main use of the endOfFile() command?
To start writing to a file
To stop reading a file
To delete a file
To rename a file
What is a record in the context of data structures?
A type of array
A collection of data values
A single data value
A type of loop
What makes records different from arrays?
Records can store only integers
Records are fixed in length
Records can store different data types
Records can be resized
What is each item in a record called?
Element
Node
Field
Index
What can you assign to each field in a record structure?
A loop and a condition
A data type and a name
A function and a parameter
A class and an object
How can you access a particular item of a record?
Using the record name only
Using the field name only
Using the variable name with a field name
Using the index number
What is the purpose of the SELECT keyword in SQL?
To specify conditions for filtering results
To sort records in ascending or descending order
To retrieve and display specific columns from a table
To search for a pattern in data
Which SQL keyword is used to filter results based on specific conditions?
SELECT
FROM
WHERE
ORDER BY
What does the % character represent in a SQL LIKE statement?
A wildcard to represent any combination of letters and numbers
A condition to filter results
An operator to sort data
A command to retrieve all fields
How can you sort records in SQL?
Using the SELECT keyword
Using the WHERE keyword
Using the ORDER BY command
Using the LIKE statement
Diagram showing SQL queries and tables with examples of SELECT, WHERE, LIKE, and ORDER BY usage.
SELECT is used to retrieve data from a database.
WHERE is used to sort the results in a specific order.
LIKE is used to filter records based on a specified pattern.
ORDER BY is used to filter records based on a condition.
What is the main difference between functions and procedures?
Functions do not return a value, while procedures do.
Functions always return a value, whereas procedures do not.
Procedures always return a value, whereas functions do not.
Both functions and procedures always return a value.
What are parameters in the context of sub programs?
The actual values that the arguments take.
The name of the sub program.
Special variables used to pass values into a sub program.
The output of a function.
How are procedures called in a program?
By assigning them to a variable.
By typing their name and giving an argument if necessary.
By using a return statement.
By defining them with parameters.
What happens if a function's return value is not assigned to a variable or used in a statement?
The function will not execute.
The return value will be stored automatically.
The return value will be lost.
The function will return an error.
Diagram showing examples of procedures and functions with code snippets.
A diagram illustrating the difference between procedures and functions.
A diagram showing examples of loops and conditionals.
A diagram depicting various data structures.
A diagram explaining the concept of recursion.
What is the purpose of the sub program in the example provided?
To add all numbers between two integers and check if the total is divisible by 7.
To multiply all numbers between two integers.
To subtract all numbers between two integers.
To divide all numbers between two integers.
What is a characteristic of local variables?
They can be used anywhere in the program.
They are invisible to the rest of the program.
They are always global.
They can affect the entire program.
How can variables in the main body of a program be made global?
By using the 'local' keyword.
By using the 'global' keyword.
By declaring them inside a sub program.
By using the 'main' keyword.
What is the advantage of local variables?
They can be used outside the sub program.
They have a global scope.
They do not affect anything outside the sub program.
They can be used in any program.
What does the sub program in the second example do?
Keeps track of a character's x and y position.
Adds two numbers.
Subtracts two numbers.
Multiplies two numbers.
Define the following data types: integer, real, boolean, character, and string.
Data structures
Data types
Data models
Data formats
What does casting mean? (Hint: It doesn't mean recruiting actors.)
Changing data type
Hiring actors
Creating variables
Writing scripts
What is meant by a constant?
A variable
A constant
A function
A loop
Why are arrays useful?
They store single values
They store multiple values
They perform calculations
They display data
What is the difference between a function and a procedure?
Functions return values, procedures do not
Procedures return values, functions do not
Both return values
Neither return values
