Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

រំឮកមេរៀនPython

Total questions: 45

Worksheet time: 23mins

Name
Class
Date
1.

In Python, what are if-statements used for?

a)

Looping

b)

Indexing

c)

Decision Making

d)

Testing

2.

What is the output of this code?


click = True

Like = 0

if click:

Like = Like + 1

print(Like)

a)

0

b)

1

c)

2

d)

3

3.

What is the output of the following code?


What is the output of following code

Temperature = 20

Thermo = 15

if Temperature < 15:

Thermo = Thermo + 5

print(Thermo)

a)

20

b)

15

c)

25

d)

10

4.
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
5.
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
6.
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 
7.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
8.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
9.
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
10.
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
11.
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
12.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
13.

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

print (people[1])

what would this result be?

a)
John
b)
Rob
c)
Bob
14.

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

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
15.

If the user enters 60, what is the output?

a)

You are old!

b)

You are middle-aged!

c)

You are young!

d)

Error message

16.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
17.

What term is used to describe data passed into/out of a program?

a)

Variable

b)

Loop

c)

Constant

d)

Parameter

18.

Consider the line of code:

Label('Go Team', 200, 100)

What is the Label?

a)

argument

b)

parameter

c)

function name

19.

Consider the line of code:

Label('Go Team', 200, 100)

What is 'Go Team' ?

a)

argument

b)

parameter

c)

function name

20.

Which of these codes is correct for creating a list of numbers?

a)

num = ('10','29','37','109')

b)

num = ['10','29','37','109']

c)

num == ('10','29','37','109')

d)

num = ['10 29 37 109']

21.

How do i remove something from a list?

a)

variable.append()

b)

variable.delete()

c)

variable.remove()

d)

variable=(new variable)

22.

What is used to separate elements in a list?

a)

Bracket

b)

Comma

c)

Full Stop

d)

Space

23.

Why is using lists beneficial?

a)

Shorter Code

b)

More Accurate

c)

It takes less time for the program to run

d)

Its not beneficial

24.

variable.sort() will do what?

a)

Sort the list into alphabetical order

b)

Sort the list into reverse order

c)

Create a new list

d)

Error

25.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

26.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

27.

data = "No Way!" The expression len(data) evaluates to:

a)

7

b)

9

c)

8

d)

6

28.

Which is the most appropriate data type for: "13th December"

a)

Float

b)

Boolean

c)

Integer

d)

String

29.

What will the output be from the following code?

print("3+4")

a)

7

b)

34

c)

3+4

d)

SyntaxError

30.

print("12"*3)

What would this print?

a)

121212

b)

36

c)

24

d)

12*3

31.

What is a Count-Controlled loop?

a)

for loop

b)

while loop

32.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

33.

What will be the output of this code?

a)

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

b)

0,2,4,6,8,10

c)

2,4,6,8,10,12

d)

2,4,6,8,10

34.

Which of these will allow me to count from 0-20 in steps of 5?

a)

for x in range(0,20):

print(x)

b)

while x = (0,20,5):

print(x)

c)

for x in range(0,21,5):

print(x)

d)

for x in range(0,21,5):

print(y)

35.

What is the error in this code?

a)

incorrect variable name

b)

incorrect indentation

c)

incorrect speech marks

d)

incorrect loop

36.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

37.

What type of list is being used in this example?

a)

Dictionary

b)

List

c)

Tuple

d)

2d Array

38.

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

39.

How many errors are there in this piece of code?

a)

0

b)

1

c)

2

d)

3

40.

Which of these is a list?

a)

fruit = ["apples", "oranges", "bananas"]

b)

fruit = "apples", "oranges", "bananas"

c)

fruit = {"apples", "oranges", "bananas"}

d)

fruit = ("apples", "oranges", "bananas")

41.
In a list called "players", if you wanted to add a player called "Bob" to the list, which of the following examples of code would be correct?
a)
players.add("Bob")
b)
player.append("Bob")
c)
players.append("Bob")
d)
players.addend("Bob")
42.

How do i remove something from a list?

a)

variable.append()

b)

variable.delete()

c)

variable.remove()

d)

variable=(new variable)

43.

An empty list can be declared as

a)

fruitList = ""

b)

fruitList = ["empty"]

c)

fruitList == []

d)

fruitList = []

44.

Which of the following commands will return the length of the list mylist?

a)

length(mylist)

b)

len(mylist)

c)

mylist.length()

d)

mylist.len()

45.

write code that will ask a user to enter a number and store it in the variable x. You should do any necessary typecasting in-line. Make your prompt say "Enter a number".

(a)