WorksheetsQ4_Quiz2_CompSciLoyalty
Total questions: 21
Worksheet time: 7mins
It is a collection which is ordered and unchangeable, and written with round brackets.
List
Tuple
Set
Dictionary
Tuple items are ordered, unchangeable, and allow duplicate values.
True
False
Since tuples are indexed, they cannot have items with the same value.
True
False
Tuples are unchangeable, meaning that we cannot change, but we can add or remove items after the tuple has been created.
True
False
To determine how many items a tuple has, use the _____ function.
type()
tuple()
append()
len()
You can access tuple items by referring to the _____, inside square brackets.
index number
key
value
data type
To print the fourth item in the tuple below, what should be the code?
car = ("Mazda", "Ford", "Nissan", "Cadillac", "BMW", "Ferrari")
print(car[4])
print(car[3])
print(thistuple[3])
print([car:4])
In tuple, you can specify a range of indexes by specifying where to start and where to end the range.
True
False
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")
print(fruits[2:5])
print(fruits[:5])
print(fruits[2:])
print(fruits[-4:-1])
You can convert the tuple into a list, change the list, and convert the list back into a tuple.
True
False
The ____ keyword can delete the tuple completely.
remove()
del
append()
erase
When we create a tuple, we normally assign values to it. This is called "____" a tuple.
unpacking
indexing
updating
packing
In Python, we are allowed to extract the values back into variables. This is called "___".
packing
unpacking
extracting
updating
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.
+
*
/
#
You can loop through the tuple items by referring to their index number.
True
False
Which of the following statements is NOT true about tuple?
You can loop through the tuple items by using a while loop.
You can loop through the tuple items by using a for loop.
A tuple is a collection which is ordered and changeable.
Tuples can have items with the same value.
Tuple items can be of any data type.
To join two or more tuples you can use the ____ operator
*
/
+
==
It searches the tuple for a specified value and returns the position of where it was found.
count()
len()
index()
tuple()
If you want to multiply the content of a tuple a given number of times, you can use the ___ operator.
^
==
*
++
Negative indexing means start from the end.
True
False
What is the output?
fruits = ("apple", "banana", "cherry", "orange", "kiwi", "melon", "mango")
print(fruits[:4])
('orange', 'kiwi', 'melon', 'mango')
('kiwi', 'melon', 'mango')
('apple', 'banana', 'cherry', 'orange', 'kiwi')
('apple', 'banana', 'cherry', 'orange')
