Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PAPER 2- PROGRAMMING- PART 1- PLS, TURTLE & BASIC PYTHON QUIZ

Total questions: 129

Worksheet time: 2hrs 38mins

Name
Class
Date
1.

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

a)

Addition

b)

Subtraction

c)

Division

d)

Multiplication

2.

Which relational operator is used to check if two values are not equal?

a)

==

b)

!=

c)

>

d)

<=

3.

What is the result of the logical operator 'and'?

a)

Returns true if either side of the test is true

b)

Returns true if both sides of the test are true

c)

Inverts the result

d)

Returns false if both sides of the test are false

4.

Which operator is used for integer division in programming?

a)

%

b)

*

c)

//

d)

**

5.

What does the logical operator 'not' do?

a)

Returns true if both sides are true

b)

Returns true if either side is true

c)

Inverts the result

d)

None of the above

6.

What is the purpose of an assignment in programming?

a)

To execute a loop

b)

To set or change the value of a variable

c)

To perform a calculation

d)

To print a message

7.

What does the 'if' statement in programming do?

a)

Repeats a command

b)

Declares a variable

c)

Executes a command if a condition is true

d)

Iterates through a data structure

8.

Which statement about the 'else' clause in programming is correct?

a)

It is mandatory in all conditional statements.

b)

It executes a command if the preceding 'if' condition is false.

c)

It defines a new variable.

d)

It repeats a command multiple times.

9.

What is the function of a 'while' loop in programming?

a)

To execute a command a fixed number of times

b)

To execute a command as long as a condition remains true

c)

To execute a command for each element in a data structure

d)

To check a condition once and execute a command

10.

How does the 'for' loop differ when using the range function with three arguments?

a)

It iterates based on a condition rather than a count.

b)

It allows multiple conditions to be checked.

c)

It influences the numbers generated by the range function with a step value.

d)

It executes without any conditions.

11.

What is the purpose of the 'def ()' syntax in programming?

a)

To declare a variable

b)

To create a function with no parameters

c)

To write data to a file

d)

To read data from a file

12.

Which command is used to display a message on the screen in Python?

a)

input()

b)

print()

c)

fileid.write()

d)

fileid.close()

13.

What does the command 'fileid = open(, "r")' do?

a)

Closes the file

b)

Writes to the file

c)

Opens a file for reading

d)

Opens a file for writing

14.

What is returned by the 'fileid.readline()' function?

a)

A list of all lines in the file

b)

The entire file content

c)

A single line from the file

d)

An empty string if the file is empty

15.

Which file mode allows you to add more content to the end of the file without modifying the existing content?

a)

"r"

b)

"w"

c)

"a"

d)

"x"

16.

What does the 'bool' subprogram return when given an ?

a)

The integer equivalent of

b)

The string equivalent of

c)

The real value equivalent of

d)

The Boolean value equivalent of

17.

Which subprogram is used to return the length of an object such as a string or a data structure?

a)

len

b)

int

c)

float

d)

ord

18.

What is the purpose of the 'input' subprogram?

a)

To print to the display

b)

To generate a list of numbers

c)

To display the content of prompt to the screen and wait for user input

d)

To return the string which matches the Unicode value of

19.

What does the 'range' subprogram do?

a)

Converts to a Boolean value

b)

Rounds a number to a specified number of decimal places

c)

Generates a list of numbers within specified start, stop, and step values

d)

Returns the integer equivalent of a character

20.

Which subprogram is used to convert an to its integer value?

a)

str

b)

int

c)

float

d)

print

21.

What does the subprogram '.append()' do in a list structure?

a)

Removes the item at a specific index

b)

Inserts an item at the beginning of the list

c)

Adds an item to the end of the list

d)

Creates a new empty list

22.

How can you remove an item from a list at a specific index using a subprogram?

a)

= list()

b)

del []

c)

.insert(, )

d)

.append()

23.

Which subprogram is used to insert an item just before an existing item at a specific index in a list?

a)

= []

b)

.append()

c)

del []

d)

.insert(, )

24.

What does the subprogram ' = list()' represent?

a)

Adds an item to the end of the list

b)

Removes an item from the list

c)

Inserts an item into the list

d)

Creates a new empty list

25.

What does the 'len' function in Python's standard library return when used with a string?

a)

The first instance of a substring

b)

The length of the string

c)

A list of substrings

d)

The original string in uppercase

26.

What will the 'string.find(, , )' function return if the substring is not found?

a)

0

b)

-1

c)

The length of the string

d)

An error message

27.

Which function is used to check if all characters in a string are alphabetic?

a)

string.isdigit()

b)

string.isalnum()

c)

string.isalpha()

d)

string.islower()

28.

What does the 'string.replace(, )' function do?

a)

Removes all occurrences of

b)

Splits the string at

c)

Replaces all occurrences of with

d)

Converts all characters to lowercase

29.

Which function would you use to convert a string to uppercase?

a)

string.lower()

b)

string.upper()

c)

string.strip()

d)

string.split()

30.

What does the '+' sign option in string formatting in Python indicate?

a)

Use a sign for both positive and negative numbers.

b)

Use a sign only for negative numbers.

c)

No sign is used.

d)

Use a sign only for positive numbers.

31.

Which alignment option is the default for most text items in Python string formatting?

a)

Right aligned

b)

Centre aligned

c)

Left aligned

d)

Justified

32.

What type specifier should be used in Python string formatting to format a number as fixed-point notation?

a)

s

b)

d

c)

f

d)

p

33.

What does the 'width' placeholder specify in Python string formatting?

a)

The alignment of the text

b)

The total number of characters in the output

c)

The number of decimal places

d)

The type of characters to be used

34.

How can you generate a line of repeated characters in Python, such as "========"?

a)

Using the '+' operator

b)

Using the '*' operator

c)

Using the '%' operator

d)

Using the '^' operator

35.

What is the purpose of the 'import ' statement in programming?

a)

To delete a library module from the program

b)

To modify a library module within the program

c)

To import the library module into the current program

d)

To export the library module out of the program

69.

What command will move the turtle in the opposite direction to t.forward()?

(a)  

70.

What is the purpose of the line 'import turtle'

a)

Imports the library of code that allows turtle to be used

b)

Creates a turtle/pen ready to draw with

c)

Imports a picture of a turtle onto your desktop

d)

Changes the icon of the arrow into the shape of a turtle

e)

Creates a screen/canvas ready to draw on

71.

What is the purpose of the line 's = turtle.getscreen()'

a)

Creates a line between the turtle and the edge of the screen

b)

Gets the position of the turtle on the screen

c)

Puts the turtle in the middle of the screen

d)

Changes the size of the screen used

e)

Creates a blank screen/canvas ready to draw on

72.

What is the purpose of the line 't = turtle.Turtle()'

a)

Creates a turtle/pen ready to draw with

b)

Creates two turtles next to each other

c)

Fetches the code from the python library needed to use turtle

d)

Changes the icon of the arrow into a turtle

e)

Draws a turtle on your screen

73.

Which of the following instructions would be needed to create this shape?

a)

t.forward()

b)

t.right()

d)

t.penup()

e)

t.pencolor("blue")

74.

If I change the line of code t.circle(50) to t.circle(100), what happens to the shape?

a)

The radius gets bigger

b)

The radius gets smaller

c)

The circle is drawn further to the right

d)

The circle is drawn further up

e)

100 circles are drawn instead of 50

75.

What is the purpose of t.pensize()?

a)

Changes the thickness of the lines drawn

b)

Increases the number of lines drawn

c)

Makes the turtle/arrow icon bigger

d)

Makes the turtle move forwards further

76.

Which of the following would move your turtle to a specific coordinate on the canvas/screen?

a)

t.goto()

b)

t.forward()

c)

t.right()

d)

t.pendown()

77.

Which of the following would move your turtle to the middle of the canvas/screen?

a)

t.home()

b)

t.backward()

c)

t.left()

d)

t.pencolor("black")

e)

t.middle()

78.

What line of code would lift the pen from the canvas so you can move elsewhere without drawing a line?

(a)  

79.

What line of code would place the pen back onto the canvas again?

(a)  

80.

How many VARIABLES are used in the code below?

import turtle
s = turtle.getscreen()
t = turtle.Turtle()
x = 10
y = 5
t.forward(y)
t.right(x)

(a)  

81.

How many functions are used in the code below?

import turtle
s = turtle.getscreen()
t = turtle.Turtle()
x = 10
y = 5
t.forward(y)
t.right(x)

(a)  

82.

What is the error with the following line of code?

t.pencolor(Blue)

a)

Colour is spelled incorrectly

b)

Blue should not have a capital B

c)

There should be speech marks around the word blue

d)

There should be a colon at the end

83.

How many times would this loop repeat?



(a)  

84.

What is the purpose of 'for' when programming in Python?

a)

To repeat a section of code a certain number of times

b)

To repeat a section of code forever

c)

To draw a square

d)

To change the colour of a shape

85.

What does the 'bg' in 't.bgcolor()' stand for?

(a)  

86.

If I want to fill the inside of a shape in a particular colour, which of the following lines would I need?

a)

t.fillcolor()

b)

t.begin_fill()

c)

t.end_fill()

d)

t.pencolor()

e)

t.forward()

87.

A 'for loop' is an example of which of the following?

a)

Selection

b)

Iteration

c)

Variable

d)

Assignment

e)

Constant

88.

Using '=' is an example of which of the following?

a)

Selection

b)

Iteration

c)

Variable

d)

Assignment

e)

Constant

89.

Which of the following functions would I use to get data from a user into my program?

a)

input()

b)

print()

c)

int()

d)

forward()

e)

pencolor()

90.

Which of the following is the name given to the : symbol

a)

Colon

b)

Apostrophe

c)

Full stop

d)

Comma

e)

Indent

91.

What is the name for the * symbol?

a)

Asterisk

b)

Star

c)

Hyphen

d)

Apostrophe

92.

What is the purpose of the * symbol?

a)

Multiplication

b)

Division

c)

Addition

d)

Subtraction

e)

To the power of (exponentiation)

93.

What is the purpose of the / symbol?

a)

Multiplication

b)

Division

c)

Addition

d)

Subtraction

e)

To the power of (exponentiation)

94.

Why would I use 'int(input())' instead of just 'input()'

a)

When I want the user to input a whole number

b)

When I want the user to input two different pieces of data

c)

When I want the user to print out a message

d)

When I want the user to merge two words into one

95.

What key do I press on the keyboard to run my code?

a)

F5

b)

Enter

c)

TAB

d)

ESC

96.

What does the operator '>' mean?

a)

Not equal to

b)

Equal to

c)

Less than

d)

Greater than

e)

Greater than or equal to

97.

What is the result of: 9 < 9

a)

True

b)

False

c)

Error

d)

18

e)

9

98.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
99.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
100.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
101.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
102.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
103.
How many times will Boo print?
a)
none
b)
4
c)
5
d)
1
104.
Which of the following best describes the order in which these lines are processed in Python?
a)
4, 1, 2
b)
4, 2, 1
c)
1, 2, 3, 4
d)
3, 1, 2
105.

Name the keyword used to define a function.

a)

define

b)

def

c)

function

d)

fu

106.

Which one is not true about function?

a)

It breaks the large program into small modules.

b)

It avoids repetition.

c)

It makes code reusable.

d)

It makes the program unorganized.

107.

How do we debug this code?

a)

Set a new background

b)

Nest line 13 under the function

c)

Use an If Statement on line 12

d)

Change line 13 to: subway_ride()

108.

How many times will the function fetch run?

a)

1 Time

b)

2 Times

c)

3 Times

d)

It will not run. There is a bug in the code.

109.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

110.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
111.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
112.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
113.

If you want to create an empty list called colours in Python, which of the following is correct?

a)

colours = [ ]

b)

colours = ( )

c)

colours = { }

d)

colours = <>

114.
What is the position of the name "Robert" in the following list:
a)
0
b)
1
c)
2
d)
3
115.
What does the APPEND procedure do in the following code:
a)
Adds Liverpool to the beginning of the list
b)
Replaces Bristol with Liverpool
c)
Replaces Manchester with Liverpool
d)
Adds Liverpool to the end of the list
116.
What output will this code produce?
a)
4
b)
2
c)
3
d)
5
117.

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

118.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

119.
a)
b)
c)
d)

1,2,3,4

120.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
121.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
d)
It ensures the code works correctly
122.
In programming, what is iteration?
a)
The repetition of steps within a program
b)
The order in which instructions are carried out
c)
A decision point in a program
d)
Testing a program to make sure it works
123.

Code for

b is greater than a

a)

a = 33

b = 200


if b > a:

print("b is greater than a")

b)

a = 33

b = 200


if b < a:

print("b is greater than a")

c)

a = 330

b = 200


if b > a:

print("b is greater than a")

124.

Inequality operator for 'greater than' ?

a)

<

b)

>

c)

<>

d)

>=

125.

Inequality operator for 'less than or equal to' ?

(a)  

126.

Meaning of >= operator?

a)

Greater than or equal to

b)

Less than or equal to

c)

Greater than

d)

Equal to

127.

Meaning of != operator?

a)

Greater than or equal to

b)

Assignment

c)

Not equal to

d)

Equal to

128.

Flowchart symbol for a decision?

a)
b)
c)
d)
129.

Which is the correct flowchart for this code?

a)
b)
c)
d)