wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz on Basic Programming Structures

Total questions: 87

Worksheet time: 46mins

Name
Class
Date
1.

What are the three basic structures that programs are built from?

a)

Sequence, Iteration, Decision

b)

Input, Output, Storage

c)

Variables, Functions, Loops

d)

Classes, Objects, Methods

2.

When thinking computationally, which of the following is NOT one of the terms we consider?

a)

Sequence

b)

Iteration

c)

Decision

d)

Compilation

3.

What is a sequence in programming?

a)

A random list of commands.

b)

A simple list of commands performed in order.

c)

A list of commands performed in reverse order.

d)

A complex list of commands with conditions.

4.

What is the first step in a sequence?

a)

Start with the last.

b)

Start with the middle.

c)

Start with the first.

d)

Start with any step.

5.

What is the process of repeating a sequence called?

a)

Iteration

b)

Recursion

c)

Compilation

d)

Execution

6.

How many times can an iteration be repeated?

a)

Only once

b)

A fixed number of times

c)

Infinite times without conditions

d)

Only twice

7.

What is another term often used for iteration?

a)

Functions

b)

Arrays

c)

Loops

d)

Variables

8.

Under what condition can an iteration be repeated zero times?

a)

When a condition is never met

b)

When a condition is always true

c)

When a condition is met once

d)

When a condition is met twice

9.

What is the process of making a choice from one or more options often called?

a)

Loops

b)

Decisions

c)

Variables

d)

Functions

10.

In decision-making, how many options can typically be chosen?

a)

Two

b)

All

c)

None

d)

One

11.

What is another term often used for decisions in programming?

a)

Loops

b)

Conditions

c)

Ifs

d)

Switches

12.

What is a variable in a computer program?

a)

A fixed value that cannot be changed

b)

A named space to store a value

c)

A type of hardware component

d)

A programming language

13.

Why is the name of a variable important in programming?

a)

It determines the speed of the program

b)

It helps to know what the variable contains

c)

It changes the data type of the variable

d)

It affects the color of the code editor

14.

What can a variable in a computer program store?

a)

Only user inputs

b)

Only sensor data

c)

Inputs from the user or a sensor, and partial results of processing

d)

Only final results of processing

15.

What is the process of breaking a problem down into smaller parts called?

a)

Integration

b)

Decomposition

c)

Compilation

d)

Aggregation

16.

What should you do until you can handle what you have in decomposition?

a)

Combine it

b)

Ignore it

c)

Break it down

d)

Expand it

17.

In decomposition, what can each of the small parts be written as in a computer program?

a)

A loop

b)

A variable

c)

A subroutine

d)

A function

18.

What is a requirement for naming subroutines?

a)

They must be named after the programmer.

b)

They should have meaningful names.

c)

They can have any random name.

d)

They must be named with numbers.

19.

What can subroutines receive to be processed?

a)

Functions

b)

Variables

c)

Data

d)

Constants

20.

What are the data received by subroutines called?

a)

Parameters

b)

Variables

c)

Constants

d)

Arguments

21.

Can subroutines return a value?

a)

Yes, always

b)

No, never

c)

Yes, sometimes

d)

Only if they are named

22.

What is a procedure in programming?

a)

A subroutine that returns a value

b)

A subroutine that does not return a value

c)

A function that always returns a value

d)

A loop that iterates indefinitely

23.

What does it mean if a procedure does not return a value?

a)

No work was done

b)

Some work was done, but there's no 'result' to work on

c)

The procedure failed

d)

The procedure is incomplete

24.

Which of the following is an example of a procedure not returning a value?

a)

Calculating a sum

b)

Drawing something on the computer screen

c)

Sorting a list

d)

Finding the maximum number

25.

What is a function in programming?

a)

A type of variable that stores data

b)

A kind of subroutine that does return a value

c)

A loop that repeats a set of instructions

d)

A method to store user inputs

26.

What does a function return?

a)

A set of instructions

b)

A user input

c)

Some information that can be worked on

d)

A graphical interface

27.

What is an example of a function's use in a transaction?

a)

Calculating the total price

b)

Calculating the change required

c)

Displaying the transaction history

d)

Printing a receipt

28.

What does the 'mousepos' function return?

a)

The color of the mouse pointer

b)

The speed of the mouse

c)

The new coordinates of the pointer

d)

The type of mouse used

29.

What happens when a subroutine is executed?

a)

It is called.

b)

It is deleted.

c)

It is ignored.

d)

It is paused.

30.

What occurs when a subroutine is called?

a)

The work continues as usual.

b)

The work is suspended.

c)

The work is accelerated.

d)

The work is canceled.

31.

What is done to the subroutine code when it is called?

a)

It is ignored.

b)

It is loaded and executed.

c)

It is deleted.

d)

It is paused.

32.

What happens once the subroutine is finished?

a)

It starts a new task.

b)

It deletes the original code.

c)

It returns control to the original code.

d)

It pauses indefinitely.

33.

What is a module in programming?

a)

A program source file

b)

A type of hardware

c)

A user interface

d)

A database

34.

What can a module contain?

a)

Only one function

b)

Lots of subroutines

c)

Only data

d)

Only comments

35.

In a big project, what does each module contain?

a)

The entire system

b)

The user manual

c)

The code for a specific part of the system

d)

The project budget

36.

What happens when you bring modules together in a project?

a)

You get a list of errors

b)

You get the finished, complete system

c)

You get a draft version

d)

You get a backup copy

37.

What is the concept of modularity as described in the text?

a)

Creating a single part to function independently

b)

Making parts separately to a predefined specification and assembling them

c)

Designing parts without any specifications

d)

Building a whole without using separate parts

38.

Which of the following is an example of modularity in cars?

a)

Processor

b)

Roof tiles

c)

Engine

d)

Keyboard

39.

Which component is NOT part of a computer's modularity as mentioned in the text?

a)

Motherboard

b)

Chassis

c)

RAM

d)

Screen

40.

According to the text, which of the following is a modular component of a house?

a)

Transmission

b)

Processor

c)

Roof tiles

d)

Entertainment

41.

What is an operator in mathematics?

a)

A number

b)

A variable

c)

A mathematical or logical instruction

d)

A function

42.

In the expression 3 + 4, what role does the '+' symbol play?

a)

It is a number

b)

It is an operator

c)

It is a variable

d)

It is a function

43.

What is the result of the operation 15 + 5?

a)

10

b)

20

c)

25

d)

30

44.

Which operator is used for finding the remainder in a division operation?

a)

/

b)

*

c)

%

d)

//

45.

What is the output of the expression 19 // 3?

a)

6

b)

6.333

c)

1

d)

3

46.

In Python, which symbol is used for exponentiation?

a)

^

b)

**

c)

//

d)

%

47.

What is the result of the operation (2 + 4) * 3?

a)

12

b)

18

c)

24

d)

6

48.

What is the output of the expression "5 == 3"?

a)

True

b)

False

c)

Error

d)

Undefined

49.

Which operator is used to check if two values are not equal in computer science?

a)

==

b)

!=

c)

>

d)

<

50.

What is the result of the expression "5 > 3"?

a)

False

b)

True

c)

Error

d)

Undefined

51.

Which of the following expressions will return True?

a)

5 <= 3

b)

5 == 3

c)

5 >= 3

d)

5 < 3

52.

What is the output of the expression "not (5 == 3)"?

a)

False

b)

True

c)

Error

d)

Undefined

53.

Which logical operator is used to combine conditions where both must be true?

a)

Or

b)

And

c)

Not

d)

Equal

54.

Why does a computer need to know the type of data stored on it?

a)

To determine the storage capacity

b)

To know what operations can be performed

c)

To increase processing speed

d)

To enhance security

55.

Which of the following operations is possible according to the text?

a)

Multiplying words

b)

Adding two Boolean values

c)

Multiplying two numbers

d)

Subtracting two strings

56.

Which data type is used to store a whole number?

a)

Float

b)

Integer

c)

String

d)

Boolean

57.

What is the abbreviation for a floating-point number in programming?

a)

int

b)

char

c)

float

d)

str

58.

Which of the following is an example of a character data type?

a)

'hello'

b)

5.7

c)

'A'

d)

True

59.

What type of data is represented by the abbreviation 'str'?

a)

Integer

b)

String

c)

Boolean

d)

Character

60.

Which data type is used to store logical values?

a)

Boolean

b)

Integer

c)

Float

d)

String

61.

What type is the variable 'sentence' in the given pseudocode?

a)

string

b)

character

c)

integer

d)

operator

62.

In the pseudocode, what is the initial value assigned to 'counter'?

a)

1

b)

0

c)

USERINPUT

d)

lengthof char

63.

What is the purpose of the 'REPEAT' loop in the pseudocode?

a)

To iterate over each character in 'sentence'

b)

To ensure 'char' is a single character

c)

To increment the 'counter'

d)

To end the program

64.

Which operator is used to compare 'character' and 'char' in the pseudocode?

a)

<-

b)

=

c)

DO

d)

INCREMENT

65.

<--- ¿Qué se despliega si ejecutas ese programa?

a)

b)

c)

d)

66.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

67.

What will this code output?

a)

nothing at all

b)

dude

c)

dude, 4 times

d)

dude, 6 times

e)

dude, 3 times

68.

In this code, what is the "i"

a)

a while loop

b)

a variable

c)

iteration

d)

a loop

e)

random letter

69.

In this code, what is "range"?

a)

a function

b)

a variable

c)

iteration

d)

a loop

e)

selection

70.

In this code, what is "for"?

a)

a function

b)

sequence

c)

iteration

d)

a while loop

e)

selection

71.

In this code, how would the code need to be changed, to print "dude" 10 times?

a)

change the "dude", to a 10

b)

change the 4, to a 10

c)

change the for, to a while

d)

change the 4, to an 11

e)

change the print to an input()

72.

What will be displayed?

a)

1,2,3,4

b)

2,3,4,5

c)

1,1,1,1

d)

1,2,3

e)

0,1,2,3

73.

Which of the following means not equal to

a)

==

b)

!=

c)

>

d)

=

74.

Why are arrows used in flowcharts

a)

To show a statement is equal to another

b)

To allow the computer to run the program

c)

To indicate a flow of direction

d)

To make them look nice

75.

Which of these? is an example of condition/decision in a while loop?

a)

Enter your name

b)

Increase count by 1

c)

An if statement

d)

A boolean operator

76.

Can a while loop contain an if statement (nested)

a)

Yes

b)

No

77.

Which of these is the python code for 'then'

a)

>

b)

<

c)

d)

:

78.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
79.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

80.

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.

a)

FOR Loop

b)

WHILE Loop

81.

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.

a)

FOR Loop

b)

WHILE Loop

82.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

83.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

84.

What is the output of this code?

a)

It would print 'So good to see you' infinite number of times

b)

There would be no output

c)

It would print an error message.

d)

It would print 'Enter correct code'.

85.

What is the final value of n?

(a)  

86.

Make this code loop three times:


in tries= 0;


while(_________ ) {

cin>> “Looping!”;

tries++;


}

a)

tries < 3

b)

answer == 3

c)

tries > 0

d)

tries < 0

87.

What is printed out here:

int x=8;

while (x<4){

cout << "WOAH!";

}

a)

NOTHING

b)

INFINITE LOOP

c)

WOAH!WOAH!WOAH!WOAH!

d)

WOAH!WOAH!WOAH!WOAH!WOAH!