Grokking Python Fundamentals
Ask Author
Back to course home

0% completed

Vote For New Content
Quiz
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

What will be the output of the below code?
fruits = ("apple", "banana", "cherry")
a, b, c = fruits
print(a, b, c)
A
apple, banana, cherry
B
banana, cherry, apple
C
cherry, apple, banana
D
Error
What is a key characteristic of a tuple in Python?
A
Mutable
B
Immutable
C
Can contain only numeric items
D
None of the above
What will be the output of the following code?
my_tuple = (0, 1, 2, 3, 4, 5)
sliced_tuple = my_tuple[-3:]
print(sliced_tuple)
A
(0, 1, 2)
B
(3, 4, 5)
C
(2, 3, 4, 5)
D
Error
What will happen if you try to change an element in a tuple?
t = (1, 2, 3)
t[1] = 4
print(t)
A
(1, 4, 3)
B
(1, 2, 4)
C
TypeError
D
Nothing, the tuple remains the same
How can you concatenate two tuples, t1 and t2?
A
t1 + t2
B
t1.append(t2)
C
t1.extend(t2)
D
t1.concat(t2)

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible