wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Revision Quiz (Print function, Variable & While Loop)

Total questions: 68

Worksheet time: 48mins

Name
Class
Date
1.

What is the purpose of the input() function?

a)

To declare a variable

b)

To take input from the user

c)

To display output to the user

d)

To end a program

2.

Python is an example of a:

a)

Text-based programming language

b)

Visual-based programming language

c)

Block-based programming language

d)

Language written in JavaScript

3.

What is a program in computer science?

a)

A set of precise instructions

b)

A programming language

c)

A machine that executes instructions

d)

A problem-solving method

4.

Which of the following is a correctly-formatted comment?

a)

&comment

b)

“”Comment””

c)

!comment

d)

#comment

5.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
6.

A data type consisting of numbers letters and symbols:

a)

String

b)

Integer

c)

Float

d)

Boolean

7.

What does term ‘debug’ mean:

a)

looking at the code

b)

a set of instructions

c)

Identify errors and fix them

d)

Making a calculation

8.

Which type of loop iterates until instructed otherwise?

a)

FOR loop

b)

WHILE loop

9.

What is the purpose of the print function in Python?

a)

To display text, numbers, or values

b)

To assign values to variables

c)

To receive keyboard input

d)

To calculate values

10.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

11.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

12.

What will the output be from the following code? print (“Hello world!”)

a)

SyntaxError

b)

“Hello world!”

c)

Hello world!

d)

Print (Hello world!)

13.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
14.

What does an if statement do?

a)

Close the program

b)

Ask a question

c)

Make a decision

d)

Write a comment

15.

Which kind of loop would be used?


I need a program that will keep letting me add money to a piggy bank until I get to £100.

a)

FOR Loop

b)

WHILE Loop

16.

What does the word "concatenation" mean?

a)
The process of separating items into distinct groups.
b)

A method of organising data in a database.

c)
The act of deleting items from a list.
d)
The act of linking things together in a series or chain.
17.

Which kind of loop would be used?


I need a program that will keep letting me add a monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

18.

Which of the following is NOT a valid way to concatenate strings in Python?

a)

"Hello" + "World"

b)

"Hello" "World"

c)

"Hello" * "World"

d)

"Hello" + " " + "World"

19.

Which kind of loop would be used?


I need a guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

20.

What is the purpose of input() function?

a)
To perform mathematical calculations.
b)
To take user input.
c)
To read files from the disk.
d)
To display output on the screen.
21.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

22.

Which of the following is a correct way to use the `input()` function to ask for a user's name?

a)

name = input("Enter your name: ")

b)

name = input(Enter your name)

c)

name = input("Enter your name")

d)

name = input(Enter your name: )

23.

Which of the following is an example of Python string?

a)
None
b)
"Hello, World!"
c)
True
d)
12345
24.

What is variable?

a)

A variable is a named storage location that can hold data & values.

b)
A variable is a graphical representation of data in a program.
c)
A variable is a type of function that performs calculations.
d)
A variable is a fixed value that cannot change during program execution.
25.

How do you assign a value to a variable in Python?

a)

Assign values using the '->' operator.

b)
Variables are assigned values by enclosing them in parentheses.
c)

Use the '=' operator to assign a value to a variable.

d)
Use the '==' operator to assign a value to a variable.
26.

The correct way to write a variable in python?

a)

my_variables=10

b)

my_variable:10

c)

my variable=10

d)

my_variable is 10

27.

How do you output the content of a variable?

a)

Use a console log statement to display the variable's content.

b)

Assign the variable to another variable to see its content.

c)
Output the variable by writing it directly in the code without any function.
d)

Use a print function to display the variable's content.

28.

What happens if you use double quotes around the variable name in the print() statement?

a)
The print() statement will throw an error.
b)
The variable will be evaluated and its value printed.
c)
The print() statement will output nothing.
d)
The print() statement will output the variable name as a string, not its value.
29.

What is the purpose of a "While Loop"?

a)

To perform repeated actions based on a condition.

b)
To define a function that returns a value
c)
To execute a block of code only once
d)
To create a fixed-size array
30.

What does indentation means in python programming?

a)
Indentation is used to comment code in Python.
b)
Indentation is the process of adding semicolons to lines of code.
c)
Indentation refers to the number of lines in a Python script.
d)

Indentation refers to the space at the beginning of a line that defines the scope of loops, functions, and conditionals.

31.

What is indentation necessary and important when coding?

a)
Indentation is only for aesthetic purposes.
b)
Indentation is not required in any programming language.
c)
Indentation has no impact on code execution.
d)
Indentation is necessary for readability, structure, and syntax in coding.
32.

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

33.
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
34.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
35.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

36.

Which type of loop iterates until instructed otherwise?

a)

FOR loop

b)

WHILE loop

37.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
38.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
39.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
40.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
41.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

42.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

43.
a)
10  8  6  4  2
b)
10
8
6
4
2
c)
2  4  6  8  10
d)
10  9  8  7  6  5  4  3  2  1
44.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
45.

Which kind of loop would be used?


I need a program that will keep letting me add money to a piggy bank until I get to £100.

a)

FOR Loop

b)

WHILE Loop

46.
a)
12  9  6  3  0
b)
0  3  6  9  12
c)
9  6  3  0
d)
0  3  6  9
47.

Which kind of loop would be used?


I need a program that will keep letting me add a monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

48.

Which kind of loop would be used?


I need a guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

49.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

50.

What does the word "concatenation" mean?

a)
The process of separating items into distinct groups.
b)

A method of organising data in a database.

c)
The act of deleting items from a list.
d)
The act of linking things together in a series or chain.
51.

What does the term "string" mean in python?

a)
A string in Python is a collection of functions used for data manipulation.
b)
A string in Python is a type of variable that can only hold numbers.
c)
A string in Python is a sequence of characters enclosed in quotes.
d)
A string in Python is a special data type that represents a list of integers.
52.

Which of the following is an example of Python string?

a)
None
b)
"Hello, World!"
c)
True
d)
12345
53.

What is variable?

a)

A variable is a named storage location that can hold data & values.

b)
A variable is a graphical representation of data in a program.
c)
A variable is a type of function that performs calculations.
d)
A variable is a fixed value that cannot change during program execution.
54.

How do you assign a value to a variable in Python?

a)

Assign values using the '->' operator.

b)
Variables are assigned values by enclosing them in parentheses.
c)

Use the '=' operator to assign a value to a variable.

d)
Use the '==' operator to assign a value to a variable.
55.

Which is a correct example of variable?

a)
y = 10
b)
5 = x
c)
x = 5
d)
x + 2 = 7
56.

How do you output the content of a variable?

a)

Use a console log statement to display the variable's content.

b)

Assign the variable to another variable to see its content.

c)
Output the variable by writing it directly in the code without any function.
d)

Use a print function to display the variable's content.

57.

What is string concatenation?

a)
String concatenation refers to the method of reversing a string.
b)
String concatenation is the technique of converting strings to numbers.
c)
String concatenation is the operation of joining two or more strings into one.
d)
String concatenation is the process of splitting a string into multiple parts.
58.

Why is it important to spell the variable name correctly?

a)
It is important to spell the variable name correctly to avoid errors and ensure the code functions as intended.
b)
Correct spelling of variable names is only necessary for documentation purposes.
c)
Variable names can be spelled incorrectly without affecting the program's performance.
d)
It is important to spell the variable name correctly to make the code look more professional.
59.

What happens if you use double quotes around the variable name in the print() statement?

a)
The print() statement will throw an error.
b)
The variable will be evaluated and its value printed.
c)
The print() statement will output nothing.
d)
The print() statement will output the variable name as a string, not its value.
60.
Variables and constants in programs need to be assigned a data type.
a)
True
b)
False
61.
What data type would be best used to record the number of people at a party?
a)
Integer
b)
Real
c)
String
d)
Boolean
62.
What data type would be best to record the exact length of a piece of string in meters?
a)
Real
b)
Boolean
c)
Decimal
d)
Integer
63.
Integers cannot store negative numbers.
a)
False
b)
True
64.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
65.

What is an integer?

a)

A number

b)

A positive number

c)

A whole number

d)

A number with a decimal part

66.

Which of these is a floating point number?

a)

3

b)

3.0

c)

7

d)

5.6

67.

Which of these is the symbol for divide in python?

a)

÷

b)

/

c)

>

68.

The symbol for multiply is

(a)