wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python exam preparation

Total questions: 18

Worksheet time: 10mins

Name
Class
Date
1.

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

2.

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

a)

"num1 + num2"

b)

1520

c)

35

3.

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

a)

Integer

b)

String

c)

Boolean

d)

Float

4.

Which one will display when this code is run?

a)
b)
c)
d)
5.
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
6.
What is the output from this program?
a)
5
7
9
A python is a non-venomous snake
done
b)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
done
c)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake 
A python is a non-venomous snake
done
d)
done
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.
What will the output be from the following code?
print("Hello" + 2 + "world")
a)
Hello 2 world
b)
Hello2world
c)
TypeError
d)
HelloHelloworld
9.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
10.

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"]

11.

The list needs one more name added to the end - "Felipe". Which piece of code below would do this?

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

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

12.

What is the output of the following list operation

aList = [10, 20, 30, 40, 50, 60, 70, 80]

print(aList[2:5])

print(aList[:4])

print(aList[3:])

a)

[20, 30, 40, 50]

[10, 20, 30, 40]

[30, 40, 50, 60, 70, 80]

b)

[30, 40, 50]

[10, 20, 30, 40]

[40, 50, 60, 70, 80]

c)

None of these

13.

What will be the output of below Python code?

list1=[8,0,9,5]


print(list1[::-1])

a)

[5,9,0,8]

b)

[8,0,9]

c)

[8,0,9,5]

d)

[0,9,5]

14.

Which of the following are valid ways to create a dictionary like this

a)
b)
c)
d)
e)
15.

What would the program display if you ran this code and entered 2 and then 3 when prompted?

a)

The total is 5.

b)

The total is 23.

c)

The total is 6.

d)

An error.

16.

You have the following dictionary definition:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What method call will delete the entry whose value is 200?

a)

delete d('bar')

b)

d.pop("bar")

c)

d.remove("bar")

d)

None of the above

17.

What will the output be for the code shown here?

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

18.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5