wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

2.2 Programming Fundamentals

Total questions: 86

Worksheet time: 46mins

Name
Class
Date
1.

Which of the following is NOT one of the three basic programming constructs used to control the flow of a program?

a)

Sequence

b)

Selection

c)

Iteration

d)

Declaration

2.

What are the common Boolean operators mentioned in the programming fundamentals?

a)

AND, OR, NOT

b)

ADD, SUBTRACT, DIVIDE

c)

TRUE, FALSE, MAYBE

d)

IF, ELSE, WHILE

3.

Which of the following is NOT a data type listed in the section on Data Types?

a)

Integer

b)

Real

c)

Object

d)

Boolean

4.

Which of the following is NOT a basic file handling operation?

a)

Open

b)

Read

c)

Write

d)

Execute

5.

What is used to store data in a structured way according to the learning material?

a)

Arrays

b)

Records

c)

Functions

d)

SQL

6.

What is essential to produce structured code in programming?

a)

Random number generation

b)

Using SQL to search for data

c)

Basic string manipulation

d)

Using subprograms (functions and procedures)

7.

What type of arrays are mentioned in the learning material for solving problems?

a)

One dimensional arrays

b)

Two dimensional arrays

c)

Three dimensional arrays

d)

Both one and two dimensional arrays

8.

What is a variable in computer programming?

a)

A data type used when storing alphanumeric characters and symbols.

b)

A section of code that is repeated.

c)

Used within a computer program to store a single piece of data. The contents can be changed.

d)

Data which is entered into the computer program.

9.

What does the term 'constant' refer to in computer programming?

a)

A section of code that is repeated a specific number of times.

b)

Data which is sent out by the computer program.

c)

Used within a computer program to store a single piece of data. The data does not change within the program.

d)

A data type used when storing alphanumeric characters and symbols.

10.

What is an operator in the context of computer programming?

a)

A data type used when storing alphanumeric characters and symbols.

b)

Used within a program to represent an action, e.g., '+' which represents addition.

c)

Data which is entered into the computer program.

d)

A section of code that is repeated until a certain condition is met.

11.

What is meant by 'iteration' in programming?

a)

When a value is set/given to a variable.

b)

When the code/instructions are all in order, so that one piece of code executes, followed by the next.

c)

One of the three basic programming constructs, where a section of code is repeated.

d)

When strings are brought together and combined.

12.

What is 'string concatenation'?

a)

When a string is altered or edited to suit the means of the program.

b)

When strings are brought together and combined.

c)

When a string is split at specific points, separating the single string into multiple strings.

d)

A data type used when storing alphanumeric characters and symbols.

13.

What is a Database used for?

a)

To store data beyond whilst the program is not running

b)

To store large amounts of data beyond whilst the program is running

c)

To manage single pieces of data per data subject

d)

To store multiple pieces of data in the same location

14.

What does a Record refer to in a database?

a)

A single column within a table

b)

A single data subject within a table

c)

The various categories for which data is collected

d)

The language used to manage a database

15.

What is the purpose of the SQL (Structured Query Language)?

a)

To extract data from within a database

b)

To store data beyond whilst the program is running

c)

To store multiple pieces of data in the same location

d)

To manage, maintain, and query a database

16.

What is the difference between a Function and a Procedure in a sub-program?

a)

A Function is used to pass data, while a Procedure is used to pass variables

b)

A Function allows for the same piece of code to be used without repetition, while a Procedure does not

c)

A Function is a sequence of instructions which return a value, while a Procedure is a sequence of instructions which do not return a value

d)

A Function is a sequence of instructions which do not return a value, while a Procedure returns a value

17.

What is a One Dimensional List used for in a program?

a)

To store multiple pieces of data per data subject, identified using two indices

b)

To store one piece of data per data subject, identified using a single index

c)

To store large amounts of data beyond whilst the program is running

d)

To extract data from within a database

18.

Which SQL query element is used to determine from which table the data will be extracted?

a)

SELECT

b)

FROM

c)

WHERE

d)

SQL Query

19.

What data type is used to store whole numbers?

a)

Character

b)

Boolean

c)

Integer

d)

Real/Float

20.

Which data type is used to store numbers that require decimal places?

a)

Integer

b)

Character

c)

Boolean

d)

Real/Float

21.

What does the Boolean data type store?

a)

Single characters

b)

Whole numbers

c)

TRUE/FALSE values

d)

Numbers with decimal places

22.

What is the process of altering a variable's data type within a program called?

a)

Arithmetic Operator

b)

Casting

c)

DIV

d)

Random

23.

What does the DIV operator find in a division operation?

a)

The remainder of a division

b)

The quotient of a division

c)

The sum of two numbers

d)

The product of two numbers

24.

What does the MOD operator find in a division operation?

a)

The quotient of a division

b)

The sum of two numbers

c)

The remainder of a division

d)

The product of two numbers

25.

Which operator is used to perform comparisons on data within a program that provides more focused results like AND, OR, NOT?

a)

Arithmetic Operator

b)

Casting

c)

DIV

d)

Boolean Operator

26.

What is the function built into Python that allows for random choices to be made, used during random number generation?

a)

Casting

b)

Arithmetic Operator

c)

Random

d)

DIV

27.

What is the main difference between a variable and a constant in a program?

a)

A) A variable is used to store data that does not change, while a constant can change at any time.

b)

B) A constant is used to store multiple pieces of data, while a variable is used for single pieces of data.

c)

C) A variable is used to store data that can change at any time, while a constant does not change throughout the program.

d)

D) There is no difference; both variable and constant can change at any time within the program.

28.

What would likely be checked later in the program example provided to verify if the user has entered the correct credentials?

a)

A) The program will check if the inputted_username and inputted_password are empty strings.

b)

B) The program will check the inputted_username and inputted_password against the correct_username and correct_password.

c)

C) The program will change the correct_username and correct_password based on user input.

d)

D) The program will ask the user to input their username and password again.

29.

What is the operator used for addition in Python programming?

a)

%

b)

/

c)

+

d)

//

30.

Which operator is used for subtraction in Python programming?

a)

*

b)

-

c)

%

d)

//

31.

In Python programming, what symbol is used for multiplication?

a)

+

b)

-

c)

*

d)

/

32.

What is the operator for division in Python programming?

a)

+

b)

*

c)

%

d)

/

33.

Which operator is used to find the modulus in Python programming?

a)

%

b)

/

c)

+

d)

*

34.

What does the '//' operator represent in Python programming?

a)

Addition

b)

Modulus

c)

Floor Division

d)

Multiplication

35.

What is the purpose of using input in a computer program?

a)

To display a message to the user

b)

To enter data into the program

c)

To store data in a file

d)

To print a message on the screen

36.

Which command is used in Python to get user input?

a)

print

b)

input

c)

get

d)

read

37.

What does the command print do in Python?

a)

It reads data from the user

b)

It saves data to a file

c)

It outputs data to the screen

d)

It inputs data from the screen

38.

What will be the output of the Python code snippet shown in the image if the user enters the name "Alex"?

4 lines
39.

What symbol is used in Python to assign a value to a variable?

a)

==

b)

=

c)

:=

d)

+=

40.

In Python, what will be the value of z after the following lines of code? x = 5 y = 10 z = x + y

a)

15

b)

5

c)

10

d)

20

41.

What are the three main constructs used when producing a computer program?

a)

Sequencing, Selection, Repetition

b)

Sequencing, Functions, Variables

c)

Input, Output, Looping

d)

Data Types, Operators, Conditionals

42.

What is sequencing in the context of programming?

a)

The process of iterating over a block of code multiple times

b)

The process of selecting different outcomes based on conditions

c)

The process of ensuring all instructions are executed in order

d)

The process of declaring and initializing variables

43.

What is selection in the context of programming?

a)

The process of iterating over a block of code multiple times

b)

The process of selecting different outcomes based on conditions

c)

The process of ensuring all instructions are executed in order

d)

The process of declaring and initializing variables

44.

What will the Python program print if the user inputs a temperature of -5?

a)

It's mild, dress sensibly!

b)

It's hot, get those shorts on!

c)

Freezing! Get a thick coat on!

d)

Error

45.

What will the Python program print if the user inputs a temperature of 15?

a)

It's mild, dress sensibly!

b)

It's hot, get those shorts on!

c)

Freezing! Get a thick coat on!

d)

Error

46.

What will the Python program print if the user inputs a temperature of 25?

a)

It's mild, dress sensibly!

b)

It's hot, get those shorts on!

c)

Freezing! Get a thick coat on!

d)

Error

47.

Which Python keyword is used to utilize selection in the provided example?

a)

for

b)

while

c)

if

d)

def

48.

What will the program output if the temperature input by the user is -3?

a)

It's mild, dress sensibly!

b)

Freezing! Get a thick coat on!

c)

It's hot, get those shorts on!

d)

No output will be displayed.

49.

What must be true for the code under the first condition to execute?

a)

The temperature must be greater than 0.

b)

The temperature must be less than or equal to 0.

c)

The temperature must be greater than or equal to 20.

d)

The temperature must be between 0 and 20.

50.

According to the text, how many elif conditions can you have in a program?

a)

Only one

b)

Exactly two

c)

As many as needed

d)

None, only if and else are allowed

51.

What is the purpose of the else clause in the program?

a)

To execute code if the temperature is less than 0.

b)

To execute code if the temperature is between 0 and 20.

c)

To execute code if none of the above conditions have been met.

d)

To execute code if the temperature is greater than or equal to 20.

52.

What is the output of the program if the temperature is 20?

a)

It's mild, dress sensibly!

b)

Freezing! Get a thick coat on!

c)

It's hot, get those shorts on!

d)

No output will be displayed.

53.

What is iteration in the context of programming?

a)

The process of debugging a section of code

b)

The process of repeating a section of code

c)

The process of compiling a section of code

d)

The process of commenting a section of code

54.

What is Count Controlled Iteration?

a)

Code is repeated until a condition is met

b)

Code is repeated a specific number of times, regardless of any condition

c)

Code is repeated based on user input

d)

Code is executed only once without repetition

55.

What is Condition Controlled Iteration?

a)

Code is repeated a specific number of times, regardless of any condition

b)

Code is repeated until a condition is met, with no specific number of times

c)

Code is executed only once without repetition

d)

Code is repeated based on user input

56.

What type of iteration is used in the Python example provided?

a)

Infinite iteration

b)

Count controlled iteration

c)

Conditional iteration

d)

Uncontrolled iteration

57.

What does the Python program do when it is run?

a)

It counts down from a number to zero.

b)

It outputs all numbers from 0 to the user's number, excluding the user's number.

c)

It outputs all numbers from 1 to the user's number, including the user's number.

d)

It repeats a message a number of times.

58.

Why is using a for loop in this Python program more efficient?

a)

It allows the user to input the number only once.

b)

It prevents the program from stopping unexpectedly.

c)

It condenses the amount of code needed to repeat an action multiple times.

d)

It makes the program run faster.

59.

What important point should be remembered about the program's output?

a)

The program includes the user's number in the output.

b)

The program stops before reaching the user's number.

c)

The program starts counting from the user's number.

d)

The program asks the user to input the number twice.

60.

What is the purpose of the while loop in the provided Python code example?

a)

To calculate the sum of test scores

b)

To repeat a block of code until a certain condition is met

c)

To print the test score entered by the user

d)

To generate random test scores between 0 and 50

61.

What will happen if the user enters a test score of 51 in the provided Python code example?

a)

The program will accept the score and move on to the next operation.

b)

The program will terminate immediately.

c)

The program will output "Invalid score entered" and prompt the user to re-enter a valid test score.

d)

The program will calculate the average score.

62.

Which of the following test scores would cause the while loop to terminate and proceed with the rest of the program in the provided Python code example?

a)

-1

b)

0

c)

51

d)

100

63.

What is the term used to describe the type of iteration shown in the Python code example?

a)

Infinite iteration

b)

Condition controlled iteration

c)

Unconditional iteration

d)

Fixed iteration

64.

What does a string refer to in Python?

a)

A sequence of characters stored inside speech marks

b)

A numerical value stored inside parentheses

c)

A list of items separated by commas

d)

A type of Python function

65.

Which of the following variables is NOT a string based on the information provided?

a)

string1

b)

string2

c)

not_a_string1

d)

string3

66.

What would be the result of storing data inside a variable without speech marks in Python?

a)

It would be stored as a string.

b)

It would be stored as an integer or cause a syntax error.

c)

It would be ignored by Python.

d)

It would automatically convert into a string.

67.

What is string manipulation in Python?

a)

Changing the integer values in a program

b)

Editing or adapting a string to ensure it is in the required format

c)

Storing variables inside speech marks

d)

Creating lists of strings

68.

What does string concatenation refer to in Python?

a)

Multiplying two or more strings

b)

Dividing one string by another

c)

Bringing together two or more strings

d)

Subtracting one string from another

69.

Which operator is used for string concatenation in Python?

a)

*

b)

/

c)

+

d)

-

70.

What will be the result of concatenating the strings '12', '06', and '1976' in the order provided?

a)

1994

b)

12061976

c)

12+06+1976

d)

An error message

71.

What happens if you try to concatenate integers in Python using the '+' operator?

a)

The integers will be concatenated as strings.

b)

The integers will be multiplied.

c)

The integers will be added together.

d)

An error message will occur.

72.

What function is used in Python to split a string into multiple strings?

a)

A) .divide()

b)

B) .separate()

c)

C) .split()

d)

D) .cut()

73.

When splitting a string at specific characters in Python, what must you specify?

a)

A) The variable to store the result

b)

B) The length of the string

c)

C) The character where the split should occur

d)

D) The number of splits to perform

74.

What will Python automatically store input as if you don't specify a data type?

a)

A) An integer

b)

B) A list

c)

C) A string

d)

D) A float

75.

Which of the following is a way to store new strings after splitting them?

a)

A) In a tuple

b)

B) In a list or separate variables

c)

C) In a dictionary

d)

D) In a set

76.

What is the purpose of splitting strings in the context provided in the image?

a)

A) To concatenate strings

b)

B) To make it easier for the user to input all their details in one entry

c)

C) To convert strings to integers

d)

D) To encrypt user data

77.

What is the purpose of the split method in the context of the program described in the image?

a)

To combine multiple strings into one

b)

To divide a string into multiple parts based on a delimiter

c)

To sort the characters in a string alphabetically

d)

To replace certain characters in a string with others

78.

What will be stored in the variable 'list_of_words' after executing the code snippet shown in the image?

a)

A single string with the user's input

b)

The user's input split into a list of numbers

c)

The user's input split into a list of words

d)

An error message

79.

When splitting a string to store in variables, why must you specify the variable names?

a)

Because the split method requires variable names to function

b)

Because you need to know the exact number of parts the string will be split into

c)

Because the split method cannot determine how many variables are needed

d)

Because it is a syntax requirement of the programming language

80.

What is the delimiter used in the code snippet to split the user's input into a list of words?

a)

A comma

b)

A semicolon

c)

A space

d)

A slash

81.

What function is used to split a string into a list, based on a specified delimiter?

a)

.join()

b)

.append()

c)

.split()

d)

.strip()

82.

What is the delimiter used in the .split function in the example provided?

a)

A comma

b)

A space

c)

A period

d)

A semicolon

83.

After splitting the string "meow snooze plethora" using the .split function, how many strings are stored in the list?

a)

1

b)

2

c)

3

d)

4

84.

What function is used to create a list from a string where each character of the string becomes an individual element in the list?

a)

split()

b)

join()

c)

list()

d)

map()

85.

What is the purpose of splitting a word into its individual characters and storing them in a list, as described in the example?

a)

To create a unique password

b)

To count the number of characters in the word

c)

To sort the characters alphabetically

d)

To find duplicate characters

86.

How can the list of individual characters be used during user login, as suggested in the text?

a)

Users must enter the entire list of characters

b)

Users must enter the word in reverse order

c)

Users must enter specific characters from the list, such as the first, third, and eighth letters

d)

Users must enter a random selection of characters from the list