Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

computers

Total questions: 36

Worksheet time: 33mins

Name
Class
Date
1.

What is the output of the following list assignment

aList = [4, 8, 12, 16]

aList[1:4] = [20, 24, 28]

print(aList)

a)

[4, 20, 24, 28, 8, 12, 16]

b)

[4, 20, 24, 28]

2.

Select all the correct options to join two lists in Python

listOne = ['a', 'b', 'c', 'd']

listTwo = ['e', 'f', 'g']

a)

newList = listOne + listTwo

b)

newList = extend(listOne, listTwo)

c)

newList = listOne.extend(listTwo)

d)

newList.extend(listOne, listTwo)

3.

What is the output of the following list function?

sampleList = [10, 20, 30, 40, 50]

sampleList.append(60)

print(sampleList)


sampleList.append(60)

print(sampleList)

a)

[10, 20, 30, 40, 50, 60]

[10, 20, 30, 40, 50, 60, 60]

b)

[10, 20, 30, 40, 50, 60]

[10, 20, 30, 40, 50, 60]

c)

both are wrong

4.

In Python, list is mutable

a)

False

b)

True

5.

Which of the following would give an error?

a)

list1=[]

b)

list1=[]*3

c)

list1=[2,8,7]

d)

None of the above

6.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

7.

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]

8.

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"

9.

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

10.

What sort of bracket is for lists?

a)

(

b)

<

c)

}

d)

[

11.

For tuples and list which is correct?

a)

List and tuples both are mutable.

b)

List is mutable whereas tuples are immutable.

c)

List and tuples both are immutable.

d)

List is immutable whereas tuples are mutable

12.

Which is a correctly declared tuple?

a)

a = ("orange", "yellow", "red")

b)

a = "orange", "yellow", "red"

c)

a = ["orange", "yellow", "red"]

d)

a = "orangeyellowred"

13.

How would you refer to 3 in the following tuple? c = ((7,5),(5,8),(0,-1),(4,3))

a)

c[0][0]

b)

c(3)

c)

c[8]

d)

c[3][1]

14.

What is the index of the following tuple: y = ()

a)

0

b)

1

c)

There is none. It is an empty tuple

15.

Can you have an empty tuple z = () or an empty string w = []?

a)

yes

b)

no

16.

Select correct ways to create an empty dictionary

a)

sampleDict = {}

b)

sampleDict = dict()

c)

sampleDict = dict{}

17.

Please select all correct ways to empty the following dictionary

student = {

"name": "Emma",

"class": 9,

"marks": 75

}

a)

del student

b)

del student[0:2]

c)

student.clear()

18.

Items are accessed by their position in a dictionary

a)

True

b)

False

19.

Dictionary keys must be immutable

a)

True

b)

False

20.

In Python, Dictionaries are immutable

a)

True

b)

False

21.

________________method removes all items from the particular dictionary.

a)

clear( )

b)

pop( )

c)

del ( )

22.

_________________ method will not only delete the item from dictionary, but also return the deleted value.

a)

del ( )

b)

pop( )

c)

Clear( )

23.

_______________this method deletes the item from the dictionary

a)

pop( )

b)

del( )

c)

clear( )

24.

Mode in the following program to open file for writing in a mode where new data will be added at the end of old data


file =open("poem.txt","__")

a)

r

b)

a

c)

w

d)

x

25.

Choose the correct statement to close a file stream named myfile:

a)

myfile.terminate()

b)

myfile.end()

c)

myfile.close()

d)

myfile.remove()

26.
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’
27.
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
28.
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’
29.
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
30.
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
31.
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
32.
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 
33.
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
34.
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
35.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
36.

What is the term for * / + -

a)

Operations

b)

Operators

c)

Operands

d)

Opticals