Font size
WorksheetsGCSE Python Programming Quiz
Total questions: 105
Worksheet time: 3600secs
What is the purpose of a debugger?
To find and fix errors in program code
To create colourful syntax
To run programs faster
To document program code
What is an input?
A program written in code
A type of storage device
information produced after processing
Data sent to a program to be processed
Typing on a keyboard is an example of an (a)
What does sequence determine?
The colour of the output
The type of input devices used
The order in which the tasks are processed
The speed of the computer
Complete the Python code to take input from a user and store it in a variable called name:
name = input (a)
What Python function is used to take data from the user during program execution?
print()
input()
USERINPUT
OUTPUT
What Python function is used to display data to the user during program execution?
print()
input()
USERINPUT
OUTPUT
What is a variable?
A named piece of data in memory that cannot be changed
A named piece of data in memory that can be accessed
A named piece of data in memory that can be changed only once
A named piece of data in memory that can be accessed and changed
What is the purpose of naming conventions?
To make the code run faster
To reduce memory usage
To improve the readability of the code
To avoid using variables
What is initialisation?
Declaring a variable
Assigning an initial value to a variable
Using a variable
Outputting a variable
Which of these are suitable variable identifiers in Python?
FirstName
favourite_food
player-one
Which statement is true for sequencing in programming?
Instructions are skipped randomly
Instructions are executed backwords
Instructions are executed from top to bottom
Instructions are executed randomly
What happens if the code sequence is incorrect?
The program may not produce the correct result
The program will execute faster
The program will execute as expected
The program will not execute at all
What is the purpose of a program?
To store data permanently
To execute instructions to achieve a specific task
To debug errors in code
To organise files on a computer
What is casting?
Changing the sequence of instructions
Finding and fixing errors in code
Changing the data type of a piece of data
Defining the actions you can perform on data
What happens if the incorrect data type is used in a program?
The program runs faster
The program may produce an error
The program may produce incorrect results
The program automatically converts the data
A (a) is a sequence of characters stored as text data
Which is an example of a float?
42
"Hello"
True
3.14
What is the result of this Python code?
int("123")
"123"
123
Error
123.00
Which data type represents True or False values?
String
Integer
Float
Boolean
Which of the following is NOT a data type?
Integer
Float
Boolean
Variable
What is an example of Boolean data?
42
"Hello World"
True
3.14
Which casting function is used to convert data to text in Python?
bool()
float()
int()
str()
What is a data type?
A specific kind of variable
Defines the data and the actions than can be carried out
A method of converting data
A fixed value within a program
What is the f-string statement used to display the value of a variable to 2 decimal places
{total: , }
{-total}
{total: .2f}
{-total: .2f}
Which of the following could be a valid output statement in Python?
Print(welcome)
print(welcome
print("welcome")
print(welcome)
What does an if statement represent?
A decision
An answer
A variable
An iteration
In Python, what is the result of an if statement
Yes or No
Wrong or Right
1 or 0
True or False
In program flow: (a) is used when there is more than one possible path for a program to follow.
Which Python function is used to get a value from a user?
print()
if
get()
input()
What is the purpose of an if statement in Python?
To repeat a set of instructions a fixed number of times times
To allow a program to follow different paths based on conditions
To repeat a set of instructions multiple times based on conditions
To execute all lines of code in a program
Which of the following is used for selection is Python
for loop
while loop
if statement
print statement
What will be output by this code?
10
5
15
20
What can be used when there are multiple conditions to check?
elif
else
otherwise
else if
What will be the output from this program?
You won!
You won! The end
The end
What will be output if the user enters "Python"?
Wrong!
Hi Pythonista
Hi Pythonista Wrong
Error
What will this program output?
small
medium
medium large
large
If a program evaluates a condition as False, what happens next?
It follows the True path
It stops running
It follows the False path
It repeats the condition
What is an arithmetic operator?
A symbol used to store a value
A symbol used to perform a maths calculation
A symbol used to perform an inequality calculation
A symbol used to perform a logical calculation
What is the result of 10 - 2 + 2 * 5?
20
18
16
14
In Python, which type of division is carried out by the // symbol?
real division
modulo division
integer division
What is the result of: 14 // 3
(a)
What does the % operator return?
The whole number from a division
The sum of two numbers
The result of a real division
The remainder of a division
What is the result of: 14 % 3
(a)
What does the // operator do?
Returns the exact result of a division
Rounds the result t the nearest whole number
Only keeps the whole number from a division
Only keeps the remainder from a division
In Python, what comes first in the order of arithmetic operations?
Indicies
Multiplication and division
Addition and subtraction
Brackets
What do relational operators do?
Perform mathematical calculations
Compare two values
Return a numeric result
Return a Boolean result
What is the result of 15 > 12?
15
3
"15 is bigger"
True
False
Complete the if statement to check if age is at least 18.
if age (a) 18:
What will be output from this program if score is 11
You lose
Not bad!
You Win!
Which of the logical operators is True when both conditions are True?
and
or
not
(5 > 3) and (10 < 20) evaluates to...
True
False
Which logical operator is used to reverse the result of a condition?
and
or
not
(8 < 3) and (5 > 2) evaluates to...
True
False
Which of the following conditions will return False?
3 > 4
(3 + 10) < (3 * 10)
(5 - 2 + 10 / 2) == 8
( 20 + 10) != (6 * 2)
The three logical operators are:
and, or and (a)
What does the Python method .lower() do when used on a string?
Converts all letters to uppercase
Converts all letters to lowercase
Checks if the string contains lowercase letters
Removes spaces from the string
In nested selection, if the outer condition is False, the inner condition will...
not execute
execute
cause an error
What will be output from this program if the user enters "Jun"?
Password:
Access granted
...Program closing
What would be output by this program if the user entered "Izzy" and then "Dog1234"?
Password:
...program closing
Password:
Access granted
...program closing
What would be output by this program if the user entered "Izzy" and then "Fish4321"?
Password:
...program closing
Password:
Access granted
...program closing
What does the .upper() method do when used on string in Python?
Converts all letters to uppercase?
Converts all letters to lowercase?
Checks if the string contains capital letters
Removes spaces from a string
How can a program check more than one username?
Use multiple elif statements
Store all usernames in a list and check using: if username in list
Use a loop a loop to ask for different usernames
Complete the Python code to convert the input string to capitals:
username = input()._______
lower
upper
lower()
upper()
What is the purpose of comments in a program?
To increase the speed of a program?
To output messages to the user
To explain parts of the code to programmers
To explain parts of the code to users
Which of these is a logical operator?
and
float
input
What does the print() function do?
Takes user input
Displays output
Ends the program
Compares values
What does the != operator mean?
Is equal to
Greater than
Is not equal to
Less than or equal to
What Python Keyword is used for condition controlled iteration?
for
while
if
not
What is iteration?
The process of storing data
Writing a new program
Comparing two values
Repeating a sequence of instructions
In a while loop, what does the condition do?
Stops the program from running
Decides if the loop should continue
Decides if the loop should stop
Creates new instructions
What happens if the condition of a while loop is False initially
The program crashes
The loop runs forever
The loop runs once
The loop never runs
What happens if the condition in a while loop is False?
The loop does not execute
The loop runs once
The loop runs forever
The loop skips to the next instruction
The condition in a while loop is checked...
at the start of the program
at the end of the program
before the iteration
after the iteration
Which of these is an example of a conditon?
print(x)
x > 10
x + 10
int(10)
What does a for loop use to control iteration?
A string
A count value
A condition
In Python, how many times would this loop iterate:
for i in range(5)
4 times
5 times
6 times
It produces an error
What will definitely end for loop?
Reaching the end of the range
A manual stop command
A break statement
Infinite conditions
Which of these is an example of iteration?
print("Hello")
x = 10
if x > 5:
for in in range(3):
What is the starting value of the variable in:
for i in range(4)
(a)
What Python keyword is used for count controlled iteration?
(a)
What does the range() function do in Python?
It creates a list of strings
It checks a condition in a loop
It generates a sequence of numbers
It stops a loop from running
Indention is important because...
It defines a block of code
It makes the code run faster
It is used to name variables
It makes no difference
What is a nested loop?
A loop that runs conditionally
A loop that runs indefinitely
A loop that runs multiple times
A loop inside another loop
What is the purpose of nested iteration?
To create infinite loops
To repeat a loop within another loop
To simplify code
To reduce iterations
What does the outer loop in a nested loop do?
Process random numbers
Controls how many times the inner loop repeats
Stops the inner loop from running
Generates output for the inner loop
What is a Python module
A collection of built-in functions
A file with pre-made code you can use in your program
A programming loop
A tool for drawing shapes
How do you add the Python module 'random' to a program?
use random()
include random
import random
add random
How do you generate a random number between 1 an 10 in Python?
random.randint(1, 10)
random.random(1, 10)
random.choice(1, 10)
random.random(1, 11)
random.randint(1, 11)
What operator is used for multiplication in Python?
%
/
*
+
What is the value of total once the program has executed?
(a)
Which statement is true?
A subroutine must be defined and executed at the same time
Subroutines make programs easier to read and understand
Procedures allow values to be returned
What does this code do?
Adds 'hamster' to the end of the list
Replaces 'cat' with 'hamster'
Adds 'hamster' at index [1], shifting the other items
Adds 'hamster' at index [0], replacing 'dog'
What will be the output from this program?
0
1
2
3
Which Python method would you use to add an item to the end of a list?
.insert()
.append()
.pop()
.remove()
What is the correct way to take 'apple' out of this list?
fruits.pop("apple")
fruits.remove("apple")
fruits.delete("apple")
fruits.cut("apple")
What is a 2D list?
A list that can only store numbers
A list that contains multiple lists
A list that is always empty
A list that can only store text
What is the index of the value 90 in this 2D list?
grades(1,2)
grades[2][1]
grades[1][2]
grades[1,2]
Which is the correct way to define a 2D list?
data = [ [1, 2, 3] , [4, 5, 6] ]
data = ( [1, 2, 3] , [4, 5, 6] )
data = { [1, 2, 3] , [4, 5, 6] }
data = < [1, 2, 3] , [4, 5, 6] >
What will be the output from this program?
(a)
Which of these correctly defines a subroutine in Python?
def myFunction:
function myFunction():
def myFunction():
subroutine myFunction():
What will be the output of this program?
3
4
5
40
In Python, access the element in the third row and second column of a 2D list called board?
board[2][1]
board[1][2]
board[3][2]
board[2,1]
Which statement correctly assigns "X" to row 1, column 3 in a 2D list?
user_board[3][1] = "X"
user_board[0][2] = "X"
user_board[3][2] = "X"
user_board = [0][2] = "X"
What will be output from this program?
2
4
6
9
