wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Review

Total questions: 16

Worksheet time: 8mins

Name
Class
Date
1.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

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

d)

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

2.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

d)

"John"

3.

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

4.

This list contains items of what data type?

a)

String

b)

Boolean

c)

Float

d)

Integer

5.

Which symbols are used to open and close a list?

a)

( ) round brackets

b)

( ) curly brackets

c)

[ ] square brackets

d)

" " speech marks

6.

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

7.

What is the function of the reverse method for lists?

a)

removes the first occurrence of the information inside the parenthesis

b)

adds the information inside the parenthesis to the end of the list

c)

reverses the order of the elements inside a list

d)

sorts the list (lowest to highest for numbers and alphabetical order for strings)

8.

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

del nameList[3]

print(nameList)

What would be the output

a)

['John', 'Harry', 'Jesse', 'Marry', 'Larry']

b)

['John', 'Harry', 'Jesse', 'John', 'Larry']

c)

['John', 'Harry', 'John', 'Marry', 'Larry']

d)

Error

9.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

10.
What Python command lets the user enter an answer to a question?
a)
answer()
b)
open()
c)
print()
d)
input()
11.

What is the resulting value of x?


double x;

x = 2.3

a)

2

b)

2.3

c)

Error

12.

What is the resulting value of x?


int x;

x = 2.3;

a)

Error

b)

2

c)

2.3

13.

What is the resulting value of x?


double x;

x = 7;

a)

Error

b)

7

c)

7.0

14.

What data type for a constant called: PI = 3.14

a)

STRING

b)

INTEGER

c)

FLOAT

d)

BOOLEAN

15.

What data type to store the price of a CD?

a)

STRING

b)

INTEGER

c)

FLOAT

d)

DATE

16.

What data type for a car plate number: plateNumber = "AV01-AFP"?

a)

STRING

b)

INTEGER

c)

FLOAT

d)

DATE