wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 60

Worksheet time: 28mins

Name
Class
Date
1.
How would you assign an integer to a variable?
a)
new_var = 4
b)
new_var == 4
c)
new_var = "4"
d)
new var "4"
2.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
3.
What does an IF statement do?
a)
Closes the program
b)
Makes a decision
c)
Asks a question
4.
Which of these would be used to loop through instructions a set number of times?
a)
IF statement
b)
WHILE loop
c)
FOR loop
5.

What will:

answer = input("Give me a number")

print(answer * 5)

output?

a)

An error message

b)

The value of answer multiplied by 5

c)

answer * 5

d)

The value of answer repeated 5 times

6.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

7.

To display something on the screen, use this command:

a)

print()

b)

Print()

c)

screen()

d)

write()

e)

display()

8.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
9.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
10.

Which operator checks if a value is equal to another value?

a)

+

b)

=

c)

==

d)

!=

11.

Which operator checks if a value is not equal to another value?

a)

==

b)

+=

c)

!=

d)

=

12.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
13.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
14.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
15.

Which is the Python logo?

a)
b)
c)
d)
16.

Which of the following would allow the user to enter data?

a)

elif

b)

output

c)

print

d)

input

17.

Which code would display 'Hello World'

a)

Print("Hello World")

b)

print("Hello World")

c)

print(Hello World)

d)

print=("hello world")

18.

What is a variable?

a)

A named memory location

b)

a value

c)

a number

d)

a letter

19.

Which of the following is NOT a suitable variable name?

a)

num1

b)

Num1

c)

MyName

d)

My name

20.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
21.
What will the output be from the following code?
print("Hello world!")
a)
SyntaxError
b)
Hello world!
c)
"Hello world!"
d)
print(Hello world!)
22.
What does the term 'debug' mean?
a)
Identify errors and fix them.
b)
Making a calculation
c)
A set of instructions
d)
Looking at code
23.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
24.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
25.

Which of the following functions display an output to the screen?

a)

display()

b)

output()

c)

print()

d)

post()

26.
What function is used to let the user answer a question?
a)
Open
b)
Print
c)
Answer
d)
Input
27.

What does the following code do?

name = input("what is your name")

a)

says hello

b)

asks for the users DOB

c)

Asks for the users name and stores it in the variable called ,name

d)

Checks information

28.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
29.

Which of the following symbols means more than?

a)

<

b)

>

c)

==

d)

!=

30.

Which of the following is correct?

a)

if colour==blue

b)

if colour=blue:

c)

if colour=="blue":

d)

if color=blue

31.

Which of these is a variable?


name=input("Welcome to the quiz, what is your name?")

print("Hello",name)

a)

input

b)

print

c)

name

d)

Hello

32.

What character is added to the end of an if, elif and else statement?

a)

:

b)

#

c)

$

d)

£

33.

The print command is an example of:

a)

Input

b)

Output

c)

Variable

d)

Selection

34.

What is the syntax error in this code?

a)

Incorrect use of variable

b)

Missing : characters at the end of the if and else statements

c)

The code is not indented correctly

d)

Missing brackets

35.

What is the syntax error in this code?

a)

Incorrect use of variable

b)

The code is not indented correctly

c)

Missing : character at the end of the else statement

d)

Missing brackets

36.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
37.
The character that must be at the end of the line for if, while, for etc.
a)
:
b)
;
c)
.
d)
,
38.

What will be the output?

name = 'Dave'

greeting = "Good morning" + name

print (greeting)

a)

greeting 'Dave'

b)

Good morning Dave

c)

Good morning name

d)

Good morning + Dave

39.
What am I? This is where a question is asked and depending on the answer, a choice is made. 
a)
Sequence
b)
Selection
c)
Iteration
40.
What am I? This is where instructions are repeated.
a)
Sequence
b)
Selection
c)
Iteration
41.
What am I? This is where instructions are done one after another.
a)
Sequence
b)
Selection
c)
Iteration
42.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
43.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
44.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
45.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
46.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
47.
What type of algorithm can you see here?
a)
Sequence
b)
Selection
c)
Iteration
48.

A count controlled loop will..

a)

Repeat code until a condition is met

b)

Repeat code a specific amount of times

c)

Repeat code a random amount of times

d)

None of the above

49.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

50.

What sort of loop is this?

a)

Count Controlled

b)

Condition Controlled

51.

Which of these is NOT a loop in python?

a)

for loop

b)

while loop

c)

nested loop

d)

if loop

52.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

53.

Instructions carried out one after another in order is a...

a)

List

b)

Sequence

c)

Collection

d)

Series

54.

A named value that can be changed while the program runs is called a...

a)

number

b)

sequence

c)

choice

d)

variable

55.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
56.
What is another word for 'iteration'?
a)
Selection
b)
Variable Assignment
c)
Repetition
d)
Sequencing
57.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5
58.

Which word completes this sentence: "Iteration makes code more ___________"

a)

Complex

b)

Efficient

c)

Simple

d)

Straightforward

59.

A FOR loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

60.

A WHILE loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop