Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming Principles

Total questions: 71

Worksheet time: 36mins

Name
Class
Date
1.

What can be used within programs and functions to organize different types of data in a computer program?

a)

Constants and variables

b)

Functions and arrays

c)

Loops and conditions

d)

Operators and expressions

2.

What is a variable in the context of computer programming?

a)

A fixed memory location

b)

A set of instructions

c)

A named memory location where data can change

d)

A data type

3.

How do we assign a value to a variable in a computer program?

a)

Using a comparison operator

b)

Using an assignment operator

c)

Using an arithmetic operator

d)

Using a logical operator

4.

Which of the following is an example of changing the value of a variable during the running of a program?

a)

age = age + 1

b)

age == age + 1

c)

age + age = 1

d)

age = age

5.

What is a constant in programming?

a)

A variable that can change during the execution of a program.

b)

A named location in memory that contains a value that does not change during the execution of a program.

c)

A function that performs a specific task.

d)

A data type that allows for different values over time.

6.

When writing code, how are constants typically identified?

a)

By using lower case letters.

b)

By using a special symbol at the beginning.

c)

By using upper case letters.

d)

By using italics.

7.

What is an array?

a)

A single value that can store multiple data types.

b)

A set of values of different data types stored under one identifier.

c)

A set of values of the same data type stored under one identifier.

d)

A function that stores multiple values.

8.

What is the size and upper bound index of the array 'studentScores' as declared in the image?

a)

SIZE = 6, UB = 5

b)

SIZE = 7, LB = 0, UB = 6

c)

SIZE = 8, UB = 7

d)

SIZE = 7, LB = 1, UB = 7

9.

How do you add a single value to an array?

a)

By calling a function with the array name and value.

b)

By assigning a value to a specific index of the array.

c)

By using a special array method.

d)

By redeclaring the array with the new value.

10.

What will be the value of 'name1' after executing the code 'String name1 = studentNames[2];'?

a)

Charlie

b)

Oran

c)

Jason

d)

Jimmy

11.

What will be the value of 'score1' after executing the code 'Int score1 = studentScores[0];'?

a)

12

b)

34

c)

56

d)

78

12.

What command is used to get input from a user in a computer program?

a)

print command

b)

Convert.ToInt32

c)

input command

d)

Console.WriteLine

13.

What is the purpose of the Convert.ToInt32(Console.ReadLine()) statement in the example code?

a)

To print a message to the console

b)

To read a line of text from the console

c)

To convert a string to an integer

d)

To declare a variable

14.

Which command is used to output information from a computer program?

a)

Convert.ToDouble

b)

Console.ReadLine

c)

input command

d)

print command

15.

What data type is used by default when reading input from the console using Console.ReadLine()?

a)

int

b)

double

c)

string

d)

DateTime

16.

Which method would you use to convert a string to a double?

a)

Convert.ToInt32

b)

Convert.ToDateTime

c)

Convert.ToDouble

d)

Console.ReadLine

17.

What can programming languages perform on the numbers stored in variables, constants, and arrays?

a)

Mathematical operations

b)

Text formatting

c)

Image processing

d)

Sound manipulation

18.

What are operands in mathematical operations?

a)

The symbols that define the type of operation

b)

The values the operator works on

c)

The result of the operation

d)

The programming language used

19.

Which of the following is NOT a computation represented by operators?

a)

Addition

b)

Multiplication

c)

Subtraction

d)

Spell checking

20.

What is the function of operators in mathematical operations?

a)

To store values in variables

b)

To carry out a mathematical function based on the operator

c)

To compare two values

d)

To define the size of an array

21.

Refer to the diagram below. What does the number 7 represent in the given example?

a)

An operator

b)

An operand

c)

The result of the operation

d)

A variable

22.

Which operator is used in programming to perform addition?

a)

A) /

b)

B) +

c)

C) *

d)

D) MOD

23.

What does the modulus operator MOD return?

a)

A) The quotient of the division

b)

B) The sum of two numbers

c)

C) The remainder of the division

d)

D) The product of two numbers

24.

How is integer division represented in Python?

a)

A) %

b)

B) //

c)

C) /

d)

D) DIV

25.

What is the result of the exponentiation operation 2 ^ 4?

a)

A) 8

b)

B) 16

c)

C) 32

d)

D) 64

26.

What is the result of the Boolean operation NOT applied to False?

a)

True

b)

False

c)

1

d)

0

27.

Which Boolean operator requires both operands to be True for the result to be True?

a)

AND

b)

OR

c)

NOT

d)

==

28.

What is the result of the operation 3 < 6?

a)

True

b)

False

c)

1

d)

0

29.

According to the rules of BODMAS, which of the following operations is evaluated first?

a)

Brackets

b)

Division

c)

Addition

d)

Subtraction

30.

What does the operator '==' signify in Boolean operations?

a)

Is greater than

b)

Is less than

c)

Is equal to

d)

Is not equal to

31.

What does the operator '>=' signify in Boolean operations?

a)

Is less than

b)

Is less than or equal to

c)

Is greater than

d)

Is greater than or equal to

32.

What does 'sequence' mean in the context of program flow?

a)

Repeating a set of instructions multiple times

b)

Executing each instruction once, in the order it is given

c)

Executing instructions in a random order

d)

Ignoring the order of instructions and executing them simultaneously

33.

What will be the output of the following code snippet? name = input("What is your name?\n") print("Hello", name)

a)

What is your name?: Hello Mike

b)

Hello Mike

c)

Mike Hello

d)

What is your name?: Mike Hello

34.

What is the purpose of using conditional statements in a program?

a)

To execute everything in a sequence without any selection

b)

To select which set of instructions to execute based on certain conditions

c)

To repeat a set of instructions multiple times

d)

To stop the program immediately

35.

What will be printed if the name entered is "Mike"?

a)

Access Denied - Wrong Password

b)

Hello Mike

c)

Access Granted

d)

Nothing will be printed

36.

What will be printed if the password entered is "password"?

a)

Access Denied - Wrong Password

b)

Hello Mike

c)

Access Granted

d)

Nothing will be printed

37.

What will be printed if the password entered is not "password"?

a)

Access Denied - Wrong Password

b)

Hello Mike

c)

Access Granted

d)

Nothing will be printed

38.

What will the system output if the user enters the password 'password' correctly?

a)

Access Granted

b)

Access Denied - Wrong Password

c)

Hello Mike

d)

Please enter password: password

39.

What will the system output if the user enters the password 'mike' incorrectly?

a)

Access Granted

b)

Access Denied - Wrong Password

c)

Hello Mike

d)

Please enter password: mike

40.

What will be the output if the age input is 15 in the given IF statement example?

a)

You are a child

b)

You are a teenager

c)

You are an adult

d)

No output

41.

Which of the following age inputs will result in the output "You are an adult" according to the given IF statement example?

a)

10

b)

13

c)

20

d)

8

42.

What is the correct sequence of conditional statements used in the example?

a)

IF > ELSE IF > ELSE

b)

IF > ELSE > ELSE IF

c)

ELSE IF > IF > ELSE

d)

ELSE > IF > ELSE IF

43.

What is iteration in the context of computer programming?

a)

The process of fixing errors in the code

b)

The repetition of a set of instructions

c)

The act of incrementing variable values

d)

The process of compiling the program

44.

Which type of loop is often referred to as count controlled loop?

a)

WHILE loop

b)

DO-WHILE loop

c)

FOR loop

d)

REPEAT-UNTIL loop

45.

What type of loop is a WHILE loop considered as?

a)

Count controlled loop

b)

Condition controlled loop

c)

Infinite loop

d)

Recursive loop

46.

Based on the example provided, what will be the output of the FOR loop?

a)

It will print "Number" followed by numbers 1 to 5

b)

It will print "Number" followed by numbers 0 to 4

c)

It will print "Number" followed by numbers 0 to 5

d)

It will print "Number" followed by numbers 1 to 6

47.

What will be the output of the following code snippet?

a)

0 1 2 3 4 5

b)

1 2 3 4 5 6

c)

0 1 2 3 4

d)

Error message

48.

What is an array in programming?

a)

A function that performs a specific task.

b)

A set of values of the same data type stored under one identifier.

c)

A single value that can change during program execution.

d)

A conditional statement that directs the flow of execution.

49.

What does it mean to declare an array or variable in a program?

a)

To assign a value to it.

b)

To use it in a function.

c)

To create it and specify its type.

d)

To update its value.

50.

How are elements in an array accessed?

a)

Using a loop.

b)

Using the element's name.

c)

Using the index.

d)

Using a conditional statement.

51.

If an array has 10 elements, what is the index of the last element?

a)

10

b)

9

c)

1

d)

0

52.

What is the result of accessing the element at index 2 in the string 'walter'?

a)

w

b)

a

c)

l

d)

t

53.

What symbol is used to concatenate strings in the provided example?

a)

*

b)

+

c)

&

d)

%

54.

What will be the output of the following code snippet? fname = 'walter' sname = 'white' name = fname + ' ' + sname

a)

walterwhite

b)

walter white

c)

walterwhite

d)

walter white

55.

What does the 'Contains' keyword return when searching for a character in a string?

a)

The index of the character

b)

The number of times the character appears

c)

True/False if the character is found or not

d)

The character itself

56.

What would the method call name.Contains("a") return for the string name = "Deighan"?

a)

True

b)

False

c)

Error

d)

None of the above

57.

What would the method call name.Contains("#") return for the string name = "Deighan"?

a)

True

b)

False

c)

Error

d)

None of the above

58.

What does the method call name.SubString(0,1) return for the string name = "Deighan"?

a)

D

b)

De

c)

e

d)

Deighan

59.

What does the method call name.SubString(3,3) return when name is "Deighan"?

a)

A) "Dei"

b)

B) "igh"

c)

C) "gah"

d)

D) "han"

60.

What keyword is used to split strings in the given example?

a)

split()

b)

divide()

c)

separate()

d)

break()

61.

What symbol is used as a delimiter to split the string in the first example?

a)

@

b)

&

c)

%

d)

#

62.

After splitting the string "Mr Deighan@Password" using the split() method, what is the value of details[1]?

a)

Mr Deighan

b)

Password

c)

@Password

d)

Mr

63.

How many elements will the array 'details' contain after splitting the string "Mr Deighan@Password@22@23@19@35"?

a)

2

b)

4

c)

5

d)

6

64.

What is the value of details[4] after splitting the string "Mr Deighan@Password@22@23@19@35"?

a)

22

b)

23

c)

19

d)

35

65.

What does the command .length do in string manipulation?

a)

Converts any data into the string data type

b)

Changes all the characters in the string to upper case

c)

Returns the number of characters in the string, including spaces

d)

Selects a particular part of a string

66.

What is the result of applying the .upper command to the string "name" if the value of name is "walter"?

a)

walter

b)

WALTER

c)

W

d)

ERROR

67.

Which command is used to change all the characters in a string to lower case?

a)

.length

b)

.upper

c)

.lower

d)

str()

68.

How do you select the third character in a string stored in the variable frame?

a)

frame[2]

b)

frame[3]

c)

frame.subString(2, 3)

d)

frame.length

69.

What does the command .subString(x,y) do?

a)

Changes all the characters in the string to upper case

b)

Returns the ASCII number of the character

c)

Converts any data into the string data type

d)

Selects a part of a string starting at index x and selects the next characters, set by y

70.

What is the output of ASC("A")?

a)

65

b)

A

c)

97

d)

119

71.

What does the command Chr() do with a number as its argument?

a)

Returns the ASCII number of the character

b)

Changes all the characters in the string to lower case

c)

Returns the character corresponding to the ASCII number

d)

Selects a particular character in the string