wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

GCSE Python Programming Quiz

Total questions: 105

Worksheet time: 3600secs

Name
Class
Date
1.

What is the purpose of a debugger?

a)

To find and fix errors in program code

b)

To create colourful syntax

c)

To run programs faster

d)

To document program code

2.

What is an input?

a)

A program written in code

b)

A type of storage device

c)

information produced after processing

d)

Data sent to a program to be processed

3.

Typing on a keyboard is an example of an (a)  

4.

What does sequence determine?

a)

The colour of the output

b)

The type of input devices used

c)

The order in which the tasks are processed

d)

The speed of the computer

5.

Complete the Python code to take input from a user and store it in a variable called name:
name = input (a)  

6.

What Python function is used to take data from the user during program execution?

a)

print()

b)

input()

c)

USERINPUT

d)

OUTPUT

7.

What Python function is used to display data to the user during program execution?

a)

print()

b)

input()

c)

USERINPUT

d)

OUTPUT

8.

What is a variable?

a)

A named piece of data in memory that cannot be changed

b)

A named piece of data in memory that can be accessed

c)

A named piece of data in memory that can be changed only once

d)

A named piece of data in memory that can be accessed and changed

9.

What is the purpose of naming conventions?

a)

To make the code run faster

b)

To reduce memory usage

c)

To improve the readability of the code

d)

To avoid using variables

10.

What is initialisation?

a)

Declaring a variable

b)

Assigning an initial value to a variable

c)

Using a variable

d)

Outputting a variable

11.

Which of these are suitable variable identifiers in Python?

a)

FirstName

b)

print

c)

favourite_food

d)

player-one

12.

Which statement is true for sequencing in programming?

a)

Instructions are skipped randomly

b)

Instructions are executed backwords

c)

Instructions are executed from top to bottom

d)

Instructions are executed randomly

13.

What happens if the code sequence is incorrect?

a)

The program may not produce the correct result

b)

The program will execute faster

c)

The program will execute as expected

d)

The program will not execute at all

14.

What is the purpose of a program?

a)

To store data permanently

b)

To execute instructions to achieve a specific task

c)

To debug errors in code

d)

To organise files on a computer

15.

What is casting?

a)

Changing the sequence of instructions

b)

Finding and fixing errors in code

c)

Changing the data type of a piece of data

d)

Defining the actions you can perform on data

16.

What happens if the incorrect data type is used in a program?

a)

The program runs faster

b)

The program may produce an error

c)

The program may produce incorrect results

d)

The program automatically converts the data

17.

A (a)   is a sequence of characters stored as text data

18.

Which is an example of a float?

a)

42

b)

"Hello"

c)

True

d)

3.14

19.

What is the result of this Python code?
int("123")

a)

"123"

b)

123

c)

Error

d)

123.00

20.

Which data type represents True or False values?

a)

String

b)

Integer

c)

Float

d)

Boolean

21.

Which of the following is NOT a data type?

a)

Integer

b)

Float

c)

Boolean

d)

Variable

22.

What is an example of Boolean data?

a)

42

b)

"Hello World"

c)

True

d)

3.14

23.

Which casting function is used to convert data to text in Python?

a)

bool()

b)

float()

c)

int()

d)

str()

24.

What is a data type?

a)

A specific kind of variable

b)

Defines the data and the actions than can be carried out

c)

A method of converting data

d)

A fixed value within a program

25.

What is the f-string statement used to display the value of a variable to 2 decimal places

a)

{total: , }

b)

{-total}

c)

{total: .2f}

d)

{-total: .2f}

26.

Which of the following could be a valid output statement in Python?

a)

Print(welcome)

b)

print(welcome

c)

print("welcome")

d)

print(welcome)

27.

What does an if statement represent?

a)

A decision

b)

An answer

c)

A variable

d)

An iteration

28.

In Python, what is the result of an if statement

a)

Yes or No

b)

Wrong or Right

c)

1 or 0

d)

True or False

29.

In program flow: (a)   is used when there is more than one possible path for a program to follow.

30.

Which Python function is used to get a value from a user?

a)

print()

b)

if

c)

get()

d)

input()

31.

What is the purpose of an if statement in Python?

a)

To repeat a set of instructions a fixed number of times times

b)

To allow a program to follow different paths based on conditions

c)

To repeat a set of instructions multiple times based on conditions

d)

To execute all lines of code in a program

32.

Which of the following is used for selection is Python

a)

for loop

b)

while loop

c)

if statement

d)

print statement

33.

What will be output by this code?

a)

10

b)

5

c)

15

d)

20

34.

What can be used when there are multiple conditions to check?

a)

elif

b)

else

c)

otherwise

d)

else if

35.

What will be the output from this program?

a)

You won!

b)

You won! The end

c)

The end

36.

What will be output if the user enters "Python"?

a)

Wrong!

b)

Hi Pythonista

c)

Hi Pythonista Wrong

d)

Error

37.

What will this program output?

a)

small

b)

medium

c)

medium large

d)

large

38.

If a program evaluates a condition as False, what happens next?

a)

It follows the True path

b)

It stops running

c)

It follows the False path

d)

It repeats the condition

39.

What is an arithmetic operator?

a)

A symbol used to store a value

b)

A symbol used to perform a maths calculation

c)

A symbol used to perform an inequality calculation

d)

A symbol used to perform a logical calculation

40.

What is the result of 10 - 2 + 2 * 5?

a)

20

b)

18

c)

16

d)

14

41.

In Python, which type of division is carried out by the // symbol?

a)

real division

b)

modulo division

c)

integer division

42.

What is the result of: 14 // 3

(a)  

43.

What does the % operator return?

a)

The whole number from a division

b)

The sum of two numbers

c)

The result of a real division

d)

The remainder of a division

44.

What is the result of: 14 % 3

(a)  

45.

What does the // operator do?

a)

Returns the exact result of a division

b)

Rounds the result t the nearest whole number

c)

Only keeps the whole number from a division

d)

Only keeps the remainder from a division

46.

In Python, what comes first in the order of arithmetic operations?

a)

Indicies

b)

Multiplication and division

c)

Addition and subtraction

d)

Brackets

47.

What do relational operators do?

a)

Perform mathematical calculations

b)

Compare two values

c)

Return a numeric result

d)

Return a Boolean result

48.

What is the result of 15 > 12?

a)

15

b)

3

c)

"15 is bigger"

d)

True

e)

False

49.

Complete the if statement to check if age is at least 18.

if age (a)   18:

50.

What will be output from this program if score is 11

a)

You lose

b)

Not bad!

c)

You Win!

51.

Which of the logical operators is True when both conditions are True?

a)

and

b)

or

c)

not

52.

(5 > 3) and (10 < 20) evaluates to...

a)

True

b)

False

53.

Which logical operator is used to reverse the result of a condition?

a)

and

b)

or

c)

not

54.

(8 < 3) and (5 > 2) evaluates to...

a)

True

b)

False

55.

Which of the following conditions will return False?

a)

3 > 4

b)

(3 + 10) < (3 * 10)

c)

(5 - 2 + 10 / 2) == 8

d)

( 20 + 10) != (6 * 2)

56.

The three logical operators are:

and, or and (a)  

57.

What does the Python method .lower() do when used on a string?

a)

Converts all letters to uppercase

b)

Converts all letters to lowercase

c)

Checks if the string contains lowercase letters

d)

Removes spaces from the string

58.

In nested selection, if the outer condition is False, the inner condition will...

a)

not execute

b)

execute

c)

cause an error

59.

What will be output from this program if the user enters "Jun"?

a)

Password:

b)

Access granted

c)

...Program closing

60.

What would be output by this program if the user entered "Izzy" and then "Dog1234"?

a)

Password:

...program closing

b)

Password:

Access granted

c)

...program closing

61.

What would be output by this program if the user entered "Izzy" and then "Fish4321"?

a)

Password:

...program closing

b)

Password:

Access granted

c)

...program closing

62.

What does the .upper() method do when used on string in Python?

a)

Converts all letters to uppercase?

b)

Converts all letters to lowercase?

c)

Checks if the string contains capital letters

d)

Removes spaces from a string

63.

How can a program check more than one username?

a)

Use multiple elif statements

b)

Store all usernames in a list and check using: if username in list

c)

Use a loop a loop to ask for different usernames

64.

Complete the Python code to convert the input string to capitals:

username = input()._______

a)

lower

b)

upper

c)

lower()

d)

upper()

65.

What is the purpose of comments in a program?

a)

To increase the speed of a program?

b)

To output messages to the user

c)

To explain parts of the code to programmers

d)

To explain parts of the code to users

66.

Which of these is a logical operator?

a)

and

b)

print

c)

float

d)

input

67.

What does the print() function do?

a)

Takes user input

b)

Displays output

c)

Ends the program

d)

Compares values

68.

What does the != operator mean?

a)

Is equal to

b)

Greater than

c)

Is not equal to

d)

Less than or equal to

69.

What Python Keyword is used for condition controlled iteration?

a)

for

b)

while

c)

if

d)

not

70.

What is iteration?

a)

The process of storing data

b)

Writing a new program

c)

Comparing two values

d)

Repeating a sequence of instructions

71.

In a while loop, what does the condition do?

a)

Stops the program from running

b)

Decides if the loop should continue

c)

Decides if the loop should stop

d)

Creates new instructions

72.

What happens if the condition of a while loop is False initially

a)

The program crashes

b)

The loop runs forever

c)

The loop runs once

d)

The loop never runs

73.

What happens if the condition in a while loop is False?

a)

The loop does not execute

b)

The loop runs once

c)

The loop runs forever

d)

The loop skips to the next instruction

74.

The condition in a while loop is checked...

a)

at the start of the program

b)

at the end of the program

c)

before the iteration

d)

after the iteration

75.

Which of these is an example of a conditon?

a)

print(x)

b)

x > 10

c)

x + 10

d)

int(10)

76.

What does a for loop use to control iteration?

a)

A string

b)

A count value

c)

A condition

77.

In Python, how many times would this loop iterate:

for i in range(5)

a)

4 times

b)

5 times

c)

6 times

d)

It produces an error

78.

What will definitely end for loop?

a)

Reaching the end of the range

b)

A manual stop command

c)

A break statement

d)

Infinite conditions

79.

Which of these is an example of iteration?

a)

print("Hello")

b)

x = 10

c)

if x > 5:

d)

for in in range(3):

80.

What is the starting value of the variable in:

for i in range(4)

(a)  

81.

What Python keyword is used for count controlled iteration?

(a)  

82.

What does the range() function do in Python?

a)

It creates a list of strings

b)

It checks a condition in a loop

c)

It generates a sequence of numbers

d)

It stops a loop from running

83.

Indention is important because...

a)

It defines a block of code

b)

It makes the code run faster

c)

It is used to name variables

d)

It makes no difference

84.

What is a nested loop?

a)

A loop that runs conditionally

b)

A loop that runs indefinitely

c)

A loop that runs multiple times

d)

A loop inside another loop

85.

What is the purpose of nested iteration?

a)

To create infinite loops

b)

To repeat a loop within another loop

c)

To simplify code

d)

To reduce iterations

86.

What does the outer loop in a nested loop do?

a)

Process random numbers

b)

Controls how many times the inner loop repeats

c)

Stops the inner loop from running

d)

Generates output for the inner loop

87.

What is a Python module

a)

A collection of built-in functions

b)

A file with pre-made code you can use in your program

c)

A programming loop

d)

A tool for drawing shapes

88.

How do you add the Python module 'random' to a program?

a)

use random()

b)

include random

c)

import random

d)

add random

89.

How do you generate a random number between 1 an 10 in Python?

a)

random.randint(1, 10)

b)

random.random(1, 10)

c)

random.choice(1, 10)

d)

random.random(1, 11)

e)

random.randint(1, 11)

90.

What operator is used for multiplication in Python?

a)

%

b)

/

c)

*

d)

+

91.

What is the value of total once the program has executed?

(a)  

92.

Which statement is true?

a)

A subroutine must be defined and executed at the same time

b)

Subroutines make programs easier to read and understand

c)

Procedures allow values to be returned

93.

What does this code do?

a)

Adds 'hamster' to the end of the list

b)

Replaces 'cat' with 'hamster'

c)

Adds 'hamster' at index [1], shifting the other items

d)

Adds 'hamster' at index [0], replacing 'dog'

94.

What will be the output from this program?

a)

0

b)

1

c)

2

d)

3

95.

Which Python method would you use to add an item to the end of a list?

a)

.insert()

b)

.append()

c)

.pop()

d)

.remove()

96.

What is the correct way to take 'apple' out of this list?

a)

fruits.pop("apple")

b)

fruits.remove("apple")

c)

fruits.delete("apple")

d)

fruits.cut("apple")

97.

What is a 2D list?

a)

A list that can only store numbers

b)

A list that contains multiple lists

c)

A list that is always empty

d)

A list that can only store text

98.

What is the index of the value 90 in this 2D list?

a)

grades(1,2)

b)

grades[2][1]

c)

grades[1][2]

d)

grades[1,2]

99.

Which is the correct way to define a 2D list?

a)

data = [ [1, 2, 3] , [4, 5, 6] ]

b)

data = ( [1, 2, 3] , [4, 5, 6] )

c)

data = { [1, 2, 3] , [4, 5, 6] }

d)

data = < [1, 2, 3] , [4, 5, 6] >

100.

What will be the output from this program?

(a)  

101.

Which of these correctly defines a subroutine in Python?

a)

def myFunction:

b)

function myFunction():

c)

def myFunction():

d)

subroutine myFunction():

102.

What will be the output of this program?

a)

3

b)

4

c)

5

d)

40

103.

In Python, access the element in the third row and second column of a 2D list called board?

a)

board[2][1]

b)

board[1][2]

c)

board[3][2]

d)

board[2,1]

104.

Which statement correctly assigns "X" to row 1, column 3 in a 2D list?

a)

user_board[3][1] = "X"

b)

user_board[0][2] = "X"

c)

user_board[3][2] = "X"

d)

user_board = [0][2] = "X"

105.

What will be output from this program?

a)

2

b)

4

c)

6

d)

9