wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Programming

Total questions: 35

Worksheet time: 3hrs 55mins

Name
Class
Date
1.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
2.
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
3.
A syntax error in your code means:
a)
You have not used enough characters. 
b)
There was no defined index. 
c)
Python can't find a file to pass the code to. 
d)
There is an error with your typing and code structure. 
4.
A program runs and, during running, is asked to divide by zero. The program crashes. This is an example of:
a)
a logic error
b)
a run-time error
c)
a logic error
d)
a user error
5.
What's the mistake in this code?
a)
Capital H in "What"
b)
Misspelling of the word "input"
c)
Capital letter missing from "print"
d)
Capital letter missing from "input"
6.
What's the mistake in this code?
a)
The variable "surname" needs a capital letter (first line of code)
b)
"print" needs a capital letter
c)
"input" needs a capital letter
d)
There are plus signs in the final line of code
7.
Which line will give a type error?
a)
First
b)
Second
c)
Third
d)
Fourth
8.
Where's the mistake?
a)
Misspelling of "print"
b)
Missing right hand bracket
c)
Missing right hand quotation mark
d)
Capital "P" for print
9.

Which is used in programming languages to map the variable and object?

a)

=

b)

==

c)

!=

d)

#

10.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
11.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
12.
What will the following lines of code print?
a)
A
b)
B C
c)
A B C
d)
Nothing, it will return an error.
13.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
14.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
15.
What will be printed to the screen?
a)
Nothing
b)
Success
c)
Failure
d)
Success
 Failure
16.
What will be printed to the screen?
a)
Success
b)
Failure
c)
Part of the way there!
d)
Nothing
17.
What will be printed to the screen?
a)
Failure
b)
Part of the way there!
c)
Success
d)
Nothing
18.
Which of the following would lead to nothing being printed?
a)
age is 17 and birth_month is 8
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 10
d)
age is 12 and birth_month is 4
19.
Which of the following would lead to "You're almost an adult!" being printed?
a)
age is 17 and birth_month is 8
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 9
d)
age is 12 and birth_month is 4
20.
Which of the following would lead to "One year closer" being printed?
a)
age is 27 and birth_month is 4
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 8
d)
age is 12 and birth_month is 12
21.
Which of the following would lead to "A few more months" being printed?
a)
age is 27 and birth_month is 4
b)
age is 16 and birth_month is 7
c)
age is 17 and birth_month is 10
d)
age is 12 and birth_month is 12
22.
The choices of an if statement are called:
a)
twigs
b)
branches
c)
leaves
d)
trees
23.
Which statement will check to see if a is both less than b and less than c?
a)
if a < b < c:
b)
if a < b and a < c:
c)
if a < b and c:
d)
if a < b and b < c
24.

1. When the following for loop is complete, how many spaces will Tracy have moved?

for i in range(5):

forward(10)

a)

50

b)

60

c)

10

d)

5

25.

How many times can you call the function in your code?

a)

once

b)

depends on the function

c)

as many times as you want

d)

not more than once

26.

1. Which of the following pieces of code will make Tracy do the following actions three times: go forward, change colors, and then turn around.

a)

for i in range(4):

forward(30)

color("blue")

left(180)

b)

for i in range(3):

forward(30)

color("blue")

left(180)

color("red")

c)

for i in range(3):

backward(30)

color("blue")

left(180)

d)

forward(30)

color("blue")

left(180)


forward(30)

color("green")

left(180)


forward(30)

color("orange")

left(180)

27.

1. Suppose you want to make Tracy draw a mountain range, like the one shown below, starting from the left side.

Which of the following functions would be the most useful function to write in order to solve this problem?

a)

def make_triangle():

b)

def change_to_red():

c)

def move_100():

d)

def my_function():

28.

Which of the following is NOT a command you can give to Tracy?

a)

left

b)

backward

c)

turn

d)

color

29.

Which of the statements below is true about indentation in Python?

a)

Indentation only matters in for loops.

b)

Indentation never matters in Python.

c)

Indentation always matters in Python.

d)

Indentation only matters in functions.

30.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
31.
What is python named after
a)
The snake
b)
Television show called Monty Python
32.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
33.
What button do you press to compile (run) your program so that it runs in the shell?
a)
F3
b)
F5
c)
F7
d)
F9
34.
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.
35.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#