Complete the code to check if set A is a subset of set B.
A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
result = A.[1](B)
print(result)The issubset method checks if all elements of set A are in set B.
Complete the code to check if set B is a superset of set A.
A = {1, 2}
B = {1, 2, 3, 4}
result = B.[1](A)
print(result)The issuperset method checks if set B contains all elements of set A.
Fix the error in the code to check if set A is a subset of set B.
A = {5, 6}
B = {4, 5, 6, 7}
result = A.[1](B)
print(result)The correct method to check if A is a subset of B is issubset. Other options are invalid or incorrect.
Fill both blanks to create a dictionary of words and their lengths, including only words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3} print(lengths)
We use len(word) to get the length, and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase keys and values only if the value is greater than 0.
data = {'a': 1, 'b': 0, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
print(result)The keys are converted to uppercase with k.upper(), values are v, and we filter values greater than 0 using >.