wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python for Middle School

Total questions: 95

Worksheet time: 44mins

Name
Class
Date
1.

Python is a

a)

text language

b)

database language

c)

programming language

2.

Python has a simple syntax similar to the

a)

coding language

b)

english language

c)

spanish language

3.

Code for Hello, World!

a)

print Hello, World!

b)

print("Hello, World!)

c)

print("Hello, World!")

4.

Code for

Five is greater than two!

a)

if 5 > 2:

print("Five is greater than two!")

b)

if 5 = 2:

print("Five is greater than two!")

c)

if 5 > 2: Print("Five is greater than two!")

5.

Code for

257

Hello, World!

a)

x = 257

y = "Hello, World!"


print(y)

print(x)

b)

x = 257

y = "Hello, World!"


print(x)

print(y)

c)

x = 257

y = Hello, World!


print x

print y

6.

Insert the missing part of the code below to output

_________________ "My name is ".

a)

Print

b)

PRINT

c)

print

7.

Comments in Python are written with a special character, which one?

a)

brackets

b)

hashtag

c)

coma

8.

Code for

b is greater than a

a)

a = 33

b = 200


if b > a:

print("b is greater than a")

b)

a = 33

b = 200


if b < a:

print("b is greater than a")

c)

a = 330

b = 200


if b > a:

print("b is greater than a")

9.

Python language use

a)

upper case letters

b)

lower case letters

c)

upper and lower case letters

10.

The output of the program

x = 4

x = "Sally"

print(x)

a)

four

b)

Saly

c)

Sally

11.
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
12.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
13.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

14.
When you have an error in your code what is the term to summarise finding and fixing that error?
a)
Error checking
b)
Debugging
c)
Syntax finder
d)
Error finder
15.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
16.
What is Python?
a)
text based programming language
b)
word processor 
c)
spreadsheet
d)
block based programming language
17.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
18.
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
19.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)

It displays an output

d)
It loops the code.
20.

What is the Python built-in function used to display numbers and text on the screen?

a)

print

b)

input

c)

output

d)

command

21.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
22.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
23.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
24.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
25.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
26.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
27.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
28.

What is the output from the following code?

print ("hello world")

a)
Hello World
b)
hello world
c)
print hello world
29.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
30.

The requirements for printing a string in Python are:

a)

( ) , ! and " "

b)

( ) and !

c)

( ) and " "

d)

" " and !

31.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)
SyntaxError
d)
Hello world!
32.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
33.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
34.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
35.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
36.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

37.
What is python named after
a)
The snake
b)
Television show called Monty Python
38.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
39.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
40.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
41.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
42.
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
43.
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
a)
/
b)
\n
c)
\l
d)
n
44.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2
45.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
46.
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
47.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
48.

people = ["John", "Rob", "Bob"]

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
49.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
50.

people = ["John", "Rob", "Bob"]

print (people[4])

what would this result be?

a)
John
b)
Rob
c)
Bob
d)
Error
51.

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

a)

display()

b)

output()

c)

print()

d)

post()

52.

Everything that we want to display in a print() function must:

a)

be inside parentheses - ()

b)

quotation marks - ""

c)

be inside single quotation marks - ''

d)

be inside hash marks - #

53.

Which operator performs a multiplication?

a)

+

b)

/

c)

X

d)

*

54.

Which operator performs a division?

a)

-

b)

+

c)

/

d)

*

55.

Which operator performs an addition?

a)

-

b)

+

c)

==

d)

/

56.

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

a)

+

b)

=

c)

==

d)

!=

57.

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

58.

Which of these is true?

a)

A syntax error will stop a program running

b)

A logic error will stop a program running

c)

A syntax error will let the program run but may have unexpected outcomes

d)

The program will always show an error message for a logic error

59.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
60.
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
61.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
62.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
63.

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

a)

display()

b)

output()

c)

print()

d)

post()

64.

Everything that we want to display in a print() function must:

a)

be inside parentheses - ()

b)

quotation marks - ""

c)

be inside single quotation marks - ''

d)

be inside hash marks - #

65.

Which operator performs a multiplication?

a)

+

b)

/

c)

X

d)

*

66.

Which operator performs a division?

a)

-

b)

+

c)

/

d)

*

67.

Which operator performs an addition?

a)

-

b)

+

c)

==

d)

/

68.

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

a)

+

b)

=

c)

==

d)

!=

69.

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

70.

Which of these is true?

a)

A syntax error will stop a program running

b)

A logic error will stop a program running

c)

A syntax error will let the program run but may have unexpected outcomes

d)

The program will always show an error message for a logic error

71.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
72.
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
73.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
74.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
75.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

76.

What would be the output of this program if the user input was 10?

a)

22.04

b)

220.4

c)

2204

d)

Error wrong data type

77.

What operator is being used in this program?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

78.

What type of list is being used in this example?

a)

Dictionary

b)

List

c)

Tuple

d)

2d Array

79.

Which of the following statements apply to tuples?

a)

They are created using square brackets

b)

They are created using curved brackets

c)

They can be amended when the program is running

d)

They can not be amended when the program is running

80.

What would be the output of this program if the user entered "yes" then "what"?

a)

Enjoy your day

b)

it is too windy for an umbrella

c)

Take an umbrella

d)

Error

81.

What would be the output of this program if the user entered "Alien"

a)

Alienway

b)

wayAlien

c)

lienAay

d)

ayAlien

82.

What data type represents a whole number?

a)

Float

b)

Int

c)

Boolean

d)

String

83.

What data type represents a decimal number?

a)

Float

b)

Int

c)

Boolean

d)

String

84.

What data type represents characters?

a)

Float

b)

Int

c)

Boolean

d)

String

85.

What data type represents only two possible outcomes?

a)

Float

b)

Int

c)

Boolean

d)

String

86.

What you the output of this program be if the user guessed "h"?

a)

Error

b)

It was heads

c)

It was tails

d)

Bad luck

87.

What shape would this code produce?

a)

5 pointed star

b)

Pentagon

c)

Sqaure

d)

Nothing it would give an error

88.

Is the following subprogram a function or procedure?

a)

Function

b)

Procedure

89.

What type of loop is being used in this program?

a)

Count controlled

b)

Condition Controlled

90.

How many errors are there in this code?

a)

1

b)

2

c)

3

d)

4

91.

How many errors are there in this piece of code?

a)

0

b)

1

c)

2

d)

3

92.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

93.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

94.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

95.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]