WorksheetsPAPER 2- PROGRAMMING- PART 1- PLS, TURTLE & BASIC PYTHON QUIZ
Total questions: 129
Worksheet time: 2hrs 38mins
What does the arithmetic operator '/' represent in programming?
Addition
Subtraction
Division
Multiplication
Which relational operator is used to check if two values are not equal?
==
!=
>
<=
What is the result of the logical operator 'and'?
Returns true if either side of the test is true
Returns true if both sides of the test are true
Inverts the result
Returns false if both sides of the test are false
Which operator is used for integer division in programming?
%
*
//
**
What does the logical operator 'not' do?
Returns true if both sides are true
Returns true if either side is true
Inverts the result
None of the above
What is the purpose of an assignment in programming?
To execute a loop
To set or change the value of a variable
To perform a calculation
To print a message
What does the 'if' statement in programming do?
Repeats a command
Declares a variable
Executes a command if a condition is true
Iterates through a data structure
Which statement about the 'else' clause in programming is correct?
It is mandatory in all conditional statements.
It executes a command if the preceding 'if' condition is false.
It defines a new variable.
It repeats a command multiple times.
What is the function of a 'while' loop in programming?
To execute a command a fixed number of times
To execute a command as long as a condition remains true
To execute a command for each element in a data structure
To check a condition once and execute a command
How does the 'for' loop differ when using the range function with three arguments?
It iterates based on a condition rather than a count.
It allows multiple conditions to be checked.
It influences the numbers generated by the range function with a step value.
It executes without any conditions.
What is the purpose of the 'def
To declare a variable
To create a function with no parameters
To write data to a file
To read data from a file
Which command is used to display a message on the screen in Python?
input(
print(
fileid.write(
fileid.close()
What does the command 'fileid = open(
Closes the file
Writes to the file
Opens a file for reading
Opens a file for writing
What is returned by the 'fileid.readline()' function?
A list of all lines in the file
The entire file content
A single line from the file
An empty string if the file is empty
Which file mode allows you to add more content to the end of the file without modifying the existing content?
"r"
"w"
"a"
"x"
What does the 'bool' subprogram return when given an
The integer equivalent of
The string equivalent of
The real value equivalent of
The Boolean value equivalent of
Which subprogram is used to return the length of an object such as a string or a data structure?
len
int
float
ord
What is the purpose of the 'input' subprogram?
To print
To generate a list of numbers
To display the content of prompt to the screen and wait for user input
To return the string which matches the Unicode value of
What does the 'range' subprogram do?
Converts
Rounds a number to a specified number of decimal places
Generates a list of numbers within specified start, stop, and step values
Returns the integer equivalent of a character
Which subprogram is used to convert an
str
int
float
What does the subprogram '.append(
Removes the item at a specific index
Inserts an item at the beginning of the list
Adds an item to the end of the list
Creates a new empty list
How can you remove an item from a list at a specific index using a subprogram?
= list()
del [
.insert(
.append(
Which subprogram is used to insert an item just before an existing item at a specific index in a list?
= []
.append(
del [
.insert(
What does the subprogram ' = list()' represent?
Adds an item to the end of the list
Removes an item from the list
Inserts an item into the list
Creates a new empty list
What does the 'len' function in Python's standard library return when used with a string?
The first instance of a substring
The length of the string
A list of substrings
The original string in uppercase
What will the 'string.find(
0
-1
The length of the string
An error message
Which function is used to check if all characters in a string are alphabetic?
string.isdigit()
string.isalnum()
string.isalpha()
string.islower()
What does the 'string.replace(
Removes all occurrences of
Splits the string at
Replaces all occurrences of
Converts all characters to lowercase
Which function would you use to convert a string to uppercase?
string.lower()
string.upper()
string.strip()
string.split()
What does the '+' sign option in string formatting in Python indicate?
Use a sign for both positive and negative numbers.
Use a sign only for negative numbers.
No sign is used.
Use a sign only for positive numbers.
Which alignment option is the default for most text items in Python string formatting?
Right aligned
Centre aligned
Left aligned
Justified
What type specifier should be used in Python string formatting to format a number as fixed-point notation?
s
d
f
p
What does the 'width' placeholder specify in Python string formatting?
The alignment of the text
The total number of characters in the output
The number of decimal places
The type of characters to be used
How can you generate a line of repeated characters in Python, such as "========"?
Using the '+' operator
Using the '*' operator
Using the '%' operator
Using the '^' operator
What is the purpose of the 'import
To delete a library module from the program
To modify a library module within the program
To import the library module into the current program
To export the library module out of the program
What does the 'random.randint(, )' function return?
A random float number between 0.0 and 1.0
A random integer between and
The smallest integer not less than
The largest integer not greater than
Which function would you use to get the square root of a number in programming?
math.ceil(
math.floor(
math.sqrt(
math.pi
What does the 'time.sleep(
Stops the program indefinitely
Advances the program by
Suspends the program for
Measures the execution time of the program
What is the default mode for a turtle in the PLS turtle graphics library module?
Logo
Standard
Basic
Advanced
How can you keep the turtle window open after the program completes?
Use turtle.pause() as the last line
Use turtle.stop() as the last line
Use turtle.done() as the last line
Use turtle.continue() as the last line
What function is used to set the size of the turtle window?
turtle.size()
turtle.window()
window.setup()
turtle.Screen().setup()
What does the turtle.screensize() function do?
Sets the size of the turtle
Makes the drawing canvas non-scrollable
Makes the drawing canvas scrollable
Closes the turtle window
What does the turtle library subprogram
Moves the turtle backward for a number of
Makes the turtle invisible
Moves the turtle forward for a number of
Turns the turtle clockwise
Which subprogram is used to make the turtle invisible?
How can you change the speed of the turtle's movement?
What is the purpose of the
To set the turtle's orientation
To move the turtle to the canvas origin
To start and end the filling of a shape
To reset the turtle's position and variables
Which subprogram is used to set the turtle's orientation to a specific degree?
What does the turtle subprogram
Changes the color of the pen
Puts the pen down on the canvas
Lifts the pen up from the canvas
Draws a circle
Which subprogram is used to set the color of the pen in Python's turtle graphics library?
What parameter is optional when using the
radius
color
extent
pensize
What does the
Draws a full circle
Draws a quarter circle
Draws a half circle
Changes the color of the circle
Which of the following is not a color mentioned in the Python turtle graphics color list provided?
Cyan
Magenta
Black
Olive
What is the purpose of introducing spaces in Python code as mentioned in the text?
To make the code run faster
To help understand the logic of the code more easily
To reduce the amount of memory used by the program
To increase the execution time of the program
Which character in Python allows for line continuation?
Period (.)
Comma (,)
Backslash (\)
Forward slash (/)
What does the carriage return (CR) ASCII character do?
Moves the cursor to the beginning of the same line
Deletes the previous character
Inserts a new line in the text
Changes the text color
How does Python handle the carriage return and line feed in the print function?
It ignores both characters
It converts them into uppercase letters
It automatically adds them so the console output appears on separate lines
It removes them from the output
What must a programmer do when handling files that involve carriage return and line feed characters?
Increase the file size
Remove or add these characters as needed using string concatenation
Encrypt these characters
Convert these characters to integers
Which function is used to output data to the shell in Python?
int()
sendtoshell()
print()
str()
Which of the following is the correct definition for 'integer'
A whole number
True/False
A combination of text, numbers and/or symbols
A decimal number
Which of the following is the correct definition for 'string'
A whole number
True/False
A combination of text, numbers and/or symbols
A decimal number
What symbols would be used to signify that data is a string?
" "
( )
* *
% %
Which of the following is an example of an integer?
13
1.56
Hello
True
Which of the following is an example of a boolean?
13
1.56
Hello
True
Which of the following is an example of a real/float?
13
1.56
Hello
True
Which of the following are reasons that I might type my code in the window over the shell?
Code can be edited after the code has run
Your code will be more efficient
Your code and your output will be separate
There will be no errors in your code
What does the function t.forward() do?
Moves the turtle forward by a number of units
Rotates the turtle to face forward
Draws a circle facing forward
Creates a square facing forward
What does the function t.left() do?
Rotates the turtle by a number of degrees to the left
Moves the turtle forward by a number of units
Rotates a shape you've created to face left
Makes the turtle leave the screen
Which of the following functions has the most similar purpose to t.left()?
What command will move the turtle in the opposite direction to t.forward()?
(a)
What is the purpose of the line 'import turtle'
Imports the library of code that allows turtle to be used
Creates a turtle/pen ready to draw with
Imports a picture of a turtle onto your desktop
Changes the icon of the arrow into the shape of a turtle
Creates a screen/canvas ready to draw on
What is the purpose of the line 's = turtle.getscreen()'
Creates a line between the turtle and the edge of the screen
Gets the position of the turtle on the screen
Puts the turtle in the middle of the screen
Changes the size of the screen used
Creates a blank screen/canvas ready to draw on
What is the purpose of the line 't = turtle.Turtle()'
Creates a turtle/pen ready to draw with
Creates two turtles next to each other
Fetches the code from the python library needed to use turtle
Changes the icon of the arrow into a turtle
Draws a turtle on your screen
Which of the following instructions would be needed to create this shape?
What is the purpose of t.pensize()?
Changes the thickness of the lines drawn
Increases the number of lines drawn
Makes the turtle/arrow icon bigger
Makes the turtle move forwards further
Which of the following would move your turtle to a specific coordinate on the canvas/screen?
t.goto()
t.forward()
t.right()
t.pendown()
Which of the following would move your turtle to the middle of the canvas/screen?
t.home()
t.backward()
t.left()
t.pencolor("black")
t.middle()
What line of code would lift the pen from the canvas so you can move elsewhere without drawing a line?
(a)
What line of code would place the pen back onto the canvas again?
(a)
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)
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)
What is the error with the following line of code?
t.pencolor(Blue)
Colour is spelled incorrectly
Blue should not have a capital B
There should be speech marks around the word blue
There should be a colon at the end
How many times would this loop repeat?
(a)
What is the purpose of 'for' when programming in Python?
To repeat a section of code a certain number of times
To repeat a section of code forever
To draw a square
To change the colour of a shape
What does the 'bg' in 't.bgcolor()' stand for?
(a)
If I want to fill the inside of a shape in a particular colour, which of the following lines would I need?
t.fillcolor()
t.begin_fill()
t.end_fill()
t.pencolor()
t.forward()
A 'for loop' is an example of which of the following?
Selection
Iteration
Variable
Assignment
Constant
Using '=' is an example of which of the following?
Selection
Iteration
Variable
Assignment
Constant
Which of the following functions would I use to get data from a user into my program?
input()
print()
int()
forward()
pencolor()
Which of the following is the name given to the : symbol
Colon
Apostrophe
Full stop
Comma
Indent
What is the name for the * symbol?
Asterisk
Star
Hyphen
Apostrophe
What is the purpose of the * symbol?
Multiplication
Division
Addition
Subtraction
To the power of (exponentiation)
What is the purpose of the / symbol?
Multiplication
Division
Addition
Subtraction
To the power of (exponentiation)
Why would I use 'int(input())' instead of just 'input()'
When I want the user to input a whole number
When I want the user to input two different pieces of data
When I want the user to print out a message
When I want the user to merge two words into one
What key do I press on the keyboard to run my code?
F5
Enter
TAB
ESC
What does the operator '>' mean?
Not equal to
Equal to
Less than
Greater than
Greater than or equal to
What is the result of: 9 < 9
True
False
Error
18
9
Name the keyword used to define a function.
define
def
function
fu
Which one is not true about function?
It breaks the large program into small modules.
It avoids repetition.
It makes code reusable.
It makes the program unorganized.
How do we debug this code?
Set a new background
Nest line 13 under the function
Use an If Statement on line 12
Change line 13 to: subway_ride()
How many times will the function fetch run?
1 Time
2 Times
3 Times
It will not run. There is a bug in the code.
What is the Python built-in function used to display numbers and text on the screen?
input
output
command
If you want to create an empty list called colours in Python, which of the following is correct?
colours = [ ]
colours = ( )
colours = { }
colours = <>
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 does the following program display?
1,2,3,4
1,2,3,4,5
counter,counter,counter,counter,counter
0,1,2,3,4,5
1,2,3,4
Code for
b is greater than a
a = 33
b = 200
if b > a:
print("b is greater than a")
a = 33
b = 200
if b < a:
print("b is greater than a")
a = 330
b = 200
if b > a:
print("b is greater than a")
Inequality operator for 'greater than' ?
<
>
<>
>=
Inequality operator for 'less than or equal to' ?
(a)
Meaning of >= operator?
Greater than or equal to
Less than or equal to
Greater than
Equal to
Meaning of != operator?
Greater than or equal to
Assignment
Not equal to
Equal to
Flowchart symbol for a decision?
Which is the correct flowchart for this code?
