wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python

Total questions: 72

Worksheet time: 40mins

Name
Class
Date
1.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
2.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

3.
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
4.
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")
5.
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
6.
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.
7.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
8.
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
9.
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’
10.
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
11.
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
12.
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
13.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
14.

What is the output from the following code?

print ("hello world")

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

The requirements for printing a string in Python are:

a)

( ) , ! and " "

b)

( ) and !

c)

( ) and " "

d)

" " and !

17.

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!")

18.
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!
19.
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
20.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
21.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
22.

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

23.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

24.

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

25.

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

26.

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

27.

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

a)

Alienway

b)

wayAlien

c)

lienAay

d)

ayAlien

28.

What data type represents a whole number?

a)

Float

b)

Int

c)

Boolean

d)

String

29.

What data type represents a decimal number?

a)

Float

b)

Int

c)

Boolean

d)

String

30.

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

31.

What type of loop is being used in this program?

a)

Count controlled

b)

Condition Controlled

32.

How many errors are there in this code?

a)

1

b)

2

c)

3

d)

4

33.

How many errors are there in this piece of code?

a)

0

b)

1

c)

2

d)

3

34.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day

b)

Today is Friday

c)

Uniform day

d)

Not Friday

35.

What is the output?

a)

condition

b)

True

c)

Program has a syntax error.

d)

3 > 2

36.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

37.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

38.

What is the output?

a)

250.0

b)

200.0

c)

300.0

d)

350.0

39.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

40.

What is the output?

a)

3

b)

3

7

c)

3

5

7

d)

7

41.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

42.

What is the output?

a)

level 3

b)

level 3

level 1

c)

level 3

level 1

NIL

d)

level 3

level 2

level 1

NIL

43.

Given the nested if-else below, what will be the value x when the code is executed successfully.

a)

0

b)

4

c)

2

d)

3

44.

Given the nested if-else structure below, what will be the value of x after code execution completes.

a)

2

b)

0

c)

3

d)

4

45.

What is the output of the following if statement?

a)

False

b)

True

46.
Which is the correct syntax?
a)
has_dog = true
b)
has_dog = True
c)
has_dog = Treu
d)
HAS_DOG = tRue
47.
An if statement must evaluate to:
a)
Right or Wrong
b)
True
c)
True or False
d)
False
48.
This operator means that one value is the same as the other value
a)
==
b)
!=
c)
>
d)
<
49.

What is the result of the code:

team = Cowboys

if team = Cowboys:

print(Dallas is #1)

a)

Error

b)

Cowboys

c)

Team

d)

Dallas is #1

50.
I am 71 years old! What will the output be?: IF you are 70 or older, say “You are aged to perfection!” ELIF you are exactly 50, say “Wow, you are half a century old!” ELSE say “You are a spring chicken!”
a)
“You are aged to perfection!”
b)
"Wow, you are half a century old!"
c)
"You are a spring chicken!"
51.
I am 18 years old! What will the output be?: IF you are 70 or older, say “You are aged to perfection!” ELIF you are exactly 50, say “Wow, you are half a century old!” ELSE say “You are a spring chicken!”
a)
"You are aged to perfection"
b)
"Wow, you are half a century old!"
c)
"You are spring chicken!"
52.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

53.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

54.
a)
b)
c)
d)

1,2,3,4

55.

#What is the output?

a)

1,2,3,4,5

b)

0,1,2,3,4

c)

1,2,3,4

d)

5,4,3,2,1

56.

#How many hallos will be printed?

a)

5

b)

None

c)

4

d)

6

57.

#What is the output?

a)

a, b, c, d, e

b)

a, a, a, a, a

c)

0,1,2,3,4

d)

e, d, c, b, a

58.
How many times does the following program print the word ‘computer’:

word= "computer"  
for num in range(1,6):
 
    print(word)
a)
5
b)
6
c)
1
d)
0
59.
What is iteration known as?
a)
Looping
b)
Crashing
c)
Repeating
60.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
61.

Which of the following programs prints ten lines?

a)

for i in range(10):

print("hi")

b)

for i = 1 to 10:

print("hi")

c)

for i in 1 - 10:

print("hi")

d)

for i from 0 to 9:

print("hi")

62.

What would be the output of the following code:

for i in range(3):

print(i)

a)

1 2 3

b)

i i i i

c)

i i i

d)

0 1 2

63.

Which of these will allow me to print all numbers from 0 to 4 ?

//0,1,2,3,4

a)

for x in range(4):

print(x)

b)

for x in range(0,4):

print(x)

c)

for x in range(1,5):

print(x)

d)

for x in range(5):

print(y)

64.

How do you define the range of a for loop in Python?

a)

By using the range() function with start, stop, and step parameters.

b)

By using the len() function with the iterable as the parameter.

c)

By using the start, stop, and step parameters directly in the for loop.

d)

By using the range() function with only the stop parameter.

65.

How many times does a for loop iterate if the range is (1, 5)?

a)

4

b)

2

c)

1

d)

3

66.

What is the output of the following code? for i in range(5, 0, -1): print(i)

a)

1

2

3

4

5

b)

1

2

3

4

c)

5

4

3

2

1

d)

4

3

2

1

67.

What is the output of the following code? for i in range(1, 6, 2): print(i)

a)

1 2 3 4 5

b)

1 2 3 4

c)

1 3 5

d)

1 3 5 7

68.

What is the output of the following code?

a)

0 1

b)

0

1

Loop End

c)

0

1

2

d)

0

1

2

Loop End

69.

What is the output of the following code?

a)

0

3

b)

0

1

c)

1

2

d)

0

2

70.

What is the output of the following code?

a)

0 2 Loop completed

b)

0 1 Loop completed

c)

0 1 2 Loop completed

d)

0

2

71.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

72.

what will this display?

a)

0,1,2,3,4,5

b)

0,1,2,3,4

c)

1,2,3,4,5

d)

Error