wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Q4_Quiz2_CompSciLoyalty

Total questions: 21

Worksheet time: 7mins

Name
Class
Date
1.

It is a collection which is ordered and unchangeable, and written with round brackets.

a)

List

b)

Tuple

c)

Set

d)

Dictionary

2.

Tuple items are ordered, unchangeable, and allow duplicate values.

a)

True

b)

False

3.

Since tuples are indexed, they cannot have items with the same value.

a)

True

b)

False

4.

Tuples are unchangeable, meaning that we cannot change, but we can add or remove items after the tuple has been created.

a)

True

b)

False

5.

To determine how many items a tuple has, use the _____ function.

a)

type()

b)

tuple()

c)

append()

d)

len()

6.

You can access tuple items by referring to the _____, inside square brackets.

a)

index number

b)

key

c)

value

d)

data type

7.

To print the fourth item in the tuple below, what should be the code?

car = ("Mazda", "Ford", "Nissan", "Cadillac", "BMW", "Ferrari")

a)

print(car[4])

b)

print(car[3])

c)

print(thistuple[3])

d)

print([car:4])

8.

In tuple, you can specify a range of indexes by specifying where to start and where to end the range.

a)

True

b)

False

9.

Based on the given tuple below, what should be the code to return the third, fourth, and fifth item?

fruits = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango")

a)

print(fruits[2:5])

b)

print(fruits[:5])

c)

print(fruits[2:])

d)

print(fruits[-4:-1])

10.

You can convert the tuple into a list, change the list, and convert the list back into a tuple.

a)

True

b)

False

11.

The ____ keyword can delete the tuple completely.

a)

remove()

b)

del

c)

append()

d)

erase

12.

When we create a tuple, we normally assign values to it. This is called "____" a tuple.

a)

unpacking

b)

indexing

c)

updating

d)

packing

13.

In Python, we are allowed to extract the values back into variables. This is called "___".

a)

packing

b)

unpacking

c)

extracting

d)

updating

14.

If the number of variables is less than the number of values, you can add ____ to the variable name and the values will be assigned to the variable as a list.

a)

+

b)

*

c)

/

d)

#

15.

You can loop through the tuple items by referring to their index number.

a)

True

b)

False

16.

Which of the following statements is NOT true about tuple?

a)

You can loop through the tuple items by using a while loop.

b)

You can loop through the tuple items by using a for loop.

c)

A tuple is a collection which is ordered and changeable.

d)

Tuples can have items with the same value.

e)

Tuple items can be of any data type.

17.

To join two or more tuples you can use the ____ operator

a)

*

b)

/

c)

+

d)

==

18.

It searches the tuple for a specified value and returns the position of where it was found.

a)

count()

b)

len()

c)

index()

d)

tuple()

19.

If you want to multiply the content of a tuple a given number of times, you can use the ___ operator.

a)

^

b)

==

c)

*

d)

++

20.

Negative indexing means start from the end.

a)

True

b)

False

21.

What is the output?

fruits = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango")
print(fruits[:4])

a)

('orange', 'kiwi', 'melon', 'mango')

b)

('kiwi', 'melon', 'mango')

c)

('apple', 'banana', 'cherry', 'orange', 'kiwi')

d)

('apple', 'banana', 'cherry', 'orange')