Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python for grade 5

Total questions: 30

Worksheet time: 16mins

Name
Class
Date
1.

Python language was developed in what year?

a)

1985

b)

2001

c)

1991

d)

1820

2.

Is python an interpreter or compiler programming language?

a)

Compiler

b)

Interpreter

3.

Python uses indentation to block code into chunks

a)

True

b)

False

4.

Python correct naming convention for constants is?

a)

firstName

b)

First_Name

c)

FIRST_NAME

d)

firstname

5.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

6.

What result will display in the shell if 15 and 20 is entered by the user?

a)

"num1 + num2"

b)

1520

c)

35

7.

What datatype will the answer be if the user enters 15 and 30?

a)

Integer

b)

String

c)

Boolean

d)

Float

8.

Which one will display when this code is run?

a)
b)
c)
d)
9.
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 
10.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
11.
Code repeated / looped until a condition has been met or a set number of times.
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
12.

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

13.
What is python named after
a)
The snake
b)
Television show called Monty Python
14.
Decides if a string only contains numbers
a)
isalpha()
b)
isnumeric()
c)
int()
d)
string()
15.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
16.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
17.
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
18.
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
19.
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
20.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
21.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
22.

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

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
23.

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
24.

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

print (people[4])

what would this result be?

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

What will be displayed after the code runs?

x = 5

print(x == 2)

a)

True

b)

0

c)

2

d)

false

26.

What is the "a" after the program is executed?

a = 2

If a<3:

print(a+1)

else:

print(a-1)

a)

3

b)

2

c)

1

d)

0

27.

What is b after the program is executed?

b = 2

if b > 4:

b = b + 2

a)

4

b)

2

c)

0

d)

нет правильного ответа

28.

x = 3

c = 0

while x > 1:

c = c +1

x = x -1

a)

3

b)

0

c)

1

d)

2

29.

What will you see after you run this code ?

a = 5

b = 10/2

print(a == b)

a)

True

b)

Error

c)

0

d)

False

30.

What is the value of c ?

a = 2

b = 5

if a > b:

c = a

else:

c = b

a)

2

b)

5

c)

0