Font size
WorksheetsQuiz on Basic Programming Structures
Total questions: 87
Worksheet time: 46mins
What are the three basic structures that programs are built from?
Sequence, Iteration, Decision
Input, Output, Storage
Variables, Functions, Loops
Classes, Objects, Methods
When thinking computationally, which of the following is NOT one of the terms we consider?
Sequence
Iteration
Decision
Compilation
What is a sequence in programming?
A random list of commands.
A simple list of commands performed in order.
A list of commands performed in reverse order.
A complex list of commands with conditions.
What is the first step in a sequence?
Start with the last.
Start with the middle.
Start with the first.
Start with any step.
What is the process of repeating a sequence called?
Iteration
Recursion
Compilation
Execution
How many times can an iteration be repeated?
Only once
A fixed number of times
Infinite times without conditions
Only twice
What is another term often used for iteration?
Functions
Arrays
Loops
Variables
Under what condition can an iteration be repeated zero times?
When a condition is never met
When a condition is always true
When a condition is met once
When a condition is met twice
What is the process of making a choice from one or more options often called?
Loops
Decisions
Variables
Functions
In decision-making, how many options can typically be chosen?
Two
All
None
One
What is another term often used for decisions in programming?
Loops
Conditions
Ifs
Switches
What is a variable in a computer program?
A fixed value that cannot be changed
A named space to store a value
A type of hardware component
A programming language
Why is the name of a variable important in programming?
It determines the speed of the program
It helps to know what the variable contains
It changes the data type of the variable
It affects the color of the code editor
What can a variable in a computer program store?
Only user inputs
Only sensor data
Inputs from the user or a sensor, and partial results of processing
Only final results of processing
What is the process of breaking a problem down into smaller parts called?
Integration
Decomposition
Compilation
Aggregation
What should you do until you can handle what you have in decomposition?
Combine it
Ignore it
Break it down
Expand it
In decomposition, what can each of the small parts be written as in a computer program?
A loop
A variable
A subroutine
A function
What is a requirement for naming subroutines?
They must be named after the programmer.
They should have meaningful names.
They can have any random name.
They must be named with numbers.
What can subroutines receive to be processed?
Functions
Variables
Data
Constants
What are the data received by subroutines called?
Parameters
Variables
Constants
Arguments
Can subroutines return a value?
Yes, always
No, never
Yes, sometimes
Only if they are named
What is a procedure in programming?
A subroutine that returns a value
A subroutine that does not return a value
A function that always returns a value
A loop that iterates indefinitely
What does it mean if a procedure does not return a value?
No work was done
Some work was done, but there's no 'result' to work on
The procedure failed
The procedure is incomplete
Which of the following is an example of a procedure not returning a value?
Calculating a sum
Drawing something on the computer screen
Sorting a list
Finding the maximum number
What is a function in programming?
A type of variable that stores data
A kind of subroutine that does return a value
A loop that repeats a set of instructions
A method to store user inputs
What does a function return?
A set of instructions
A user input
Some information that can be worked on
A graphical interface
What is an example of a function's use in a transaction?
Calculating the total price
Calculating the change required
Displaying the transaction history
Printing a receipt
What does the 'mousepos' function return?
The color of the mouse pointer
The speed of the mouse
The new coordinates of the pointer
The type of mouse used
What happens when a subroutine is executed?
It is called.
It is deleted.
It is ignored.
It is paused.
What occurs when a subroutine is called?
The work continues as usual.
The work is suspended.
The work is accelerated.
The work is canceled.
What is done to the subroutine code when it is called?
It is ignored.
It is loaded and executed.
It is deleted.
It is paused.
What happens once the subroutine is finished?
It starts a new task.
It deletes the original code.
It returns control to the original code.
It pauses indefinitely.
What is a module in programming?
A program source file
A type of hardware
A user interface
A database
What can a module contain?
Only one function
Lots of subroutines
Only data
Only comments
In a big project, what does each module contain?
The entire system
The user manual
The code for a specific part of the system
The project budget
What happens when you bring modules together in a project?
You get a list of errors
You get the finished, complete system
You get a draft version
You get a backup copy
What is the concept of modularity as described in the text?
Creating a single part to function independently
Making parts separately to a predefined specification and assembling them
Designing parts without any specifications
Building a whole without using separate parts
Which of the following is an example of modularity in cars?
Processor
Roof tiles
Engine
Keyboard
Which component is NOT part of a computer's modularity as mentioned in the text?
Motherboard
Chassis
RAM
Screen
According to the text, which of the following is a modular component of a house?
Transmission
Processor
Roof tiles
Entertainment
What is an operator in mathematics?
A number
A variable
A mathematical or logical instruction
A function
In the expression 3 + 4, what role does the '+' symbol play?
It is a number
It is an operator
It is a variable
It is a function
What is the result of the operation 15 + 5?
10
20
25
30
Which operator is used for finding the remainder in a division operation?
/
*
%
//
What is the output of the expression 19 // 3?
6
6.333
1
3
In Python, which symbol is used for exponentiation?
^
**
//
%
What is the result of the operation (2 + 4) * 3?
12
18
24
6
What is the output of the expression "5 == 3"?
True
False
Error
Undefined
Which operator is used to check if two values are not equal in computer science?
==
!=
>
<
What is the result of the expression "5 > 3"?
False
True
Error
Undefined
Which of the following expressions will return True?
5 <= 3
5 == 3
5 >= 3
5 < 3
What is the output of the expression "not (5 == 3)"?
False
True
Error
Undefined
Which logical operator is used to combine conditions where both must be true?
Or
And
Not
Equal
Why does a computer need to know the type of data stored on it?
To determine the storage capacity
To know what operations can be performed
To increase processing speed
To enhance security
Which of the following operations is possible according to the text?
Multiplying words
Adding two Boolean values
Multiplying two numbers
Subtracting two strings
Which data type is used to store a whole number?
Float
Integer
String
Boolean
What is the abbreviation for a floating-point number in programming?
int
char
float
str
Which of the following is an example of a character data type?
'hello'
5.7
'A'
True
What type of data is represented by the abbreviation 'str'?
Integer
String
Boolean
Character
Which data type is used to store logical values?
Boolean
Integer
Float
String
What type is the variable 'sentence' in the given pseudocode?
string
character
integer
operator
In the pseudocode, what is the initial value assigned to 'counter'?
1
0
USERINPUT
lengthof char
What is the purpose of the 'REPEAT' loop in the pseudocode?
To iterate over each character in 'sentence'
To ensure 'char' is a single character
To increment the 'counter'
To end the program
Which operator is used to compare 'character' and 'char' in the pseudocode?
<-
=
DO
INCREMENT
<--- ¿Qué se despliega si ejecutas ese programa?
Look at the following code, what will it generate
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What will this code output?
nothing at all
dude
dude, 4 times
dude, 6 times
dude, 3 times
In this code, what is the "i"
a while loop
a variable
iteration
a loop
random letter
In this code, what is "range"?
a function
a variable
iteration
a loop
selection
In this code, what is "for"?
a function
sequence
iteration
a while loop
selection
In this code, how would the code need to be changed, to print "dude" 10 times?
change the "dude", to a 10
change the 4, to a 10
change the for, to a while
change the 4, to an 11
change the print to an input()
What will be displayed?
1,2,3,4
2,3,4,5
1,1,1,1
1,2,3
0,1,2,3
Which of the following means not equal to
==
!=
>
=
Why are arrows used in flowcharts
To show a statement is equal to another
To allow the computer to run the program
To indicate a flow of direction
To make them look nice
Which of these? is an example of condition/decision in a while loop?
Enter your name
Increase count by 1
An if statement
A boolean operator
Can a while loop contain an if statement (nested)
Yes
No
Which of these is the python code for 'then'
>
<
∞
:
4
3
2
1
3
2
1
0
Which kind of loop would be used?
I need a revision program that will run through revision questions 4 times.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a guessing game program that will let me keep guessing until I get the right answer.
FOR Loop
WHILE Loop
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to £100.
FOR Loop
WHILE Loop
A condition is
a statement that is either True or False
a string
an integer
a list
WHILE loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
What is the output of this code?
It would print 'So good to see you' infinite number of times
There would be no output
It would print an error message.
It would print 'Enter correct code'.
What is the final value of n?
(a)
Make this code loop three times:
in tries= 0;
while(_________ ) {
cin>> “Looping!”;
tries++;
}
tries < 3
answer == 3
tries > 0
tries < 0
What is printed out here:
int x=8;
while (x<4){
cout << "WOAH!";
}
NOTHING
INFINITE LOOP
WOAH!WOAH!WOAH!WOAH!
WOAH!WOAH!WOAH!WOAH!WOAH!
