Complete the code to check the data type of the variable 'x'.
x = 10 print(type([1]))
Using type(x) returns the data type of the variable x.
Complete the code to check if the variable 'data' is a list.
data = [1, 2, 3] print(isinstance(data, [1]))
dict or tuple instead of list.type() with isinstance().isinstance(data, list) checks if data is a list.
Fix the error in the code to correctly check if 'value' is a string.
value = 'hello' if isinstance(value, [1]): print('It is a string')
String or string.The correct Python type for strings is str (all lowercase).
Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.
words = ['apple', 'bat', 'car', 'door'] lengths = {word: [1] for word in words if len(word) [2] 3 }
The dictionary comprehension uses len(word) to get length and filters words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values for words longer than 3 characters.
words = ['apple', 'bat', 'car', 'door'] result = { [1]: [2] for w in words if len(w) [3] 3 }
The dictionary comprehension uses w.upper() as keys, len(w) as values, and filters words with length greater than 3 using >.