Lesson T2.3.1
T2.3.1 Procedures and functions Quiz: KS3 Computing, Unit 2
20 questions
In partnership with Revision Ninja
Lesson T2.3.1, Procedures and functions: 20 multiple choice questions for the KS3 Computing (National Curriculum), Unit 2: Programming, written with Revision Ninja.
Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.
The 20 questions
-
What is a procedure?
- A single number that is stored for later use inside the program
- A list that stores a set of items in order, each with its own index
- A named block of code that carries out a task and can be called when needed
- A loop that repeats until the computer is turned off by the user
-
What does a function return?
- A picture that is shown on the screen
- A complete copy of the whole program
- An error message in every case
- A value back to the code that called it
-
Python defines the function def double(n): return n * 2. What does double(5) give?
- 25
- 10
- 7
- 5
-
What is a parameter?
- A name given to a program when it is saved to the computer's disk
- A loop that stops after a set number of steps has been completed
- A value passed into a procedure or function when it is called
- The colour used to draw a button on screen when the program starts
-
Why are procedures useful?
- They make the program longer and harder to read for other programmers
- They stop the program from ever needing any input from the user
- They replace the need for variables by storing values in the code itself
- They let the same code be reused without copying it many times
-
What is the difference between a procedure and a function?
- A function returns a value, while a procedure carries out a task
- There is no difference between the two
- A function can only be used on numbers
- A procedure returns a value, while a function never does
-
A function called area takes width and height and returns width times height. What does area(3, 4) return?
- 12
- 1
- 34
- 7
-
Which is a good name for a procedure that draws a square?
- x1
- draw_square
- thing2
- stuff
-
What happens when a procedure is called?
- The program stops running immediately
- The procedure is deleted from memory
- The instructions inside it are carried out
- The procedure changes into a number
-
A function is given the list [2, 4, 6] and returns the total of its items. What is returned?
- 6
- 3
- 12
- 24
-
Why should a function have a clear single purpose?
- So that it always returns the same number
- So it is easier to test, understand and reuse
- So that the program uses no variables
- So that it can never be called by other code
-
A procedure is called three times. How many times are its instructions carried out?
- Once only, no matter how often it is called
- Ten times, because each call repeats it
- Zero times, because it is only defined
- Three times
-
What is the result of a function that has no return statement in Python?
- It always gives back the number zero
- It causes the program to stop with an error
- It gives back the value None
- It gives back the whole program code
-
A function is defined as def add(a, b): return a + b. What is add(2, 9)?
- 2
- 7
- 29
- 11
-
Why might a programmer give a function a parameter instead of using a fixed value inside it?
- So the function can never be changed later
- So the same function can work with different values
- So the function runs without any input
- So the function becomes a list of numbers
-
What is the purpose of a function's name?
- To identify the function so that it can be called
- To set the speed at which it runs on the processor
- To store the value it returns in memory for later use
- To decide the colour of its output on screen
-
Which statement best describes a procedure in a game?
- The name of the game shown on the title screen when it first loads
- A reusable block such as play_sound that can be called from many places
- A list of all the players who have joined the game so far this week
- A single number that counts the player's score as the game is played
-
A function calculates the average of a list. Which value does it return?
- The number of items in the list only
- The first item in the list
- A copy of the list with no changes
- The average of the list items
-
Why are functions and procedures described as building blocks of a program?
- They are the only parts of a program that the computer can run
- They make the program smaller by removing all instructions
- They can be combined to build larger programs from smaller parts
- They replace the need for any data in a program
-
A procedure prints 'Well done' when it is called. What is printed after it is called twice?
- Well done, printed five times
- Well done, printed twice
- Well done, printed once
- Nothing is printed at all
Related quizzes
- Solving problems with two or more programming languages Quiz · T2.1.1 · 20 questions
- Textual programming languages Quiz · T2.1.2 · 20 questions
- Lists, tables and arrays Quiz · T2.2.1 · 20 questions
- Designing and developing modular programs Quiz · T2.3.2 · 20 questions
- Computational abstractions of real-world systems Quiz · T1.1.1 · 20 questions
- AND, OR and NOT Quiz · T3.1.1 · 20 questions
- Hardware and software components Quiz · T4.1.1 · 20 questions
- Combining applications across devices Quiz · T5.1.1 · 20 questions
- Using technology safely, respectfully and responsibly Quiz · T6.1.1 · 20 questions
- Sorting algorithms Quiz · T1.2.1 · 20 questions