Question | Click to View Answer |
What does the following code print? something = (1, "bob", True)
print(something)
|
|
What does the following code print? letters = ("a", "g", "f")
print(letters[1])
|
The Remember that unordered connections like dictionaries and sets cannot be indexed. |
What does the following code print? letters = ("a", "g", "f")
print(letters[-1])
|
Negative indexing can be used to fetch items from the end of the tuple. -1 is the last position in the tuple, -2 is the second to last position in the tuple, and so forth. |
What does the following code print? clothes = ("sock", "belt", "hat")
clothes[0] = "pants"
print(clothes)
|
This code raises a TypeError with the following message: 'tuple' object does not support item assignment. Tuples are immutable so items in a tuple cannot be replaced. |
What does the following code print? t1 = ("a",)
t2 = ("b",)
t3 = t1 + t2
print(t3)
|
The Single element tuples like |
What does the following code print? phones = ("iphone", "samsung", "iphone")
print(phones.count("iphone"))
|
The |
What does the following code print? heaters = ("oven", "stove")
print("microwave" in heaters)
|
The |
What does the following code print? happy_stuff = ("smile", "laugh", "sing")
for word in happy_stuff:
print(f"I like to {word}")
|
The following lines are printed: I like to smile
I like to laugh
I like to sing
|
What does the following code print? print(any((False, False, False)))
|
|
What does the following code print? print(any((False, True, False)))
|
|
What does the following code print? print(min((90, 4, 88)))
|
The |