0
0
Data Analysis Pythondata~10 mins

Checking data types in Data Analysis Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check the data type of the variable 'x'.

Data Analysis Python
x = 10
print(type([1]))
Drag options to blanks, or click blank then click option'
A10
B'x'
Cx
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the variable name in quotes, which checks the type of a string.
Passing the value directly instead of the variable.
2fill in blank
medium

Complete the code to check if the variable 'data' is a list.

Data Analysis Python
data = [1, 2, 3]
print(isinstance(data, [1]))
Drag options to blanks, or click blank then click option'
Aset
Btuple
Cdict
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using dict or tuple instead of list.
Confusing type() with isinstance().
3fill in blank
hard

Fix the error in the code to correctly check if 'value' is a string.

Data Analysis Python
value = 'hello'
if isinstance(value, [1]):
    print('It is a string')
Drag options to blanks, or click blank then click option'
AStr
Bstr
Cstring
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized or incorrect type names like String or string.
Forgetting that Python types are case-sensitive.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Data Analysis Python
words = ['apple', 'bat', 'car', 'door']
lengths = {word: [1] for word in words if len(word) [2] 3 }
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator like < instead of >.
Using the word itself instead of its length.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values for words longer than 3 characters.

Data Analysis Python
words = ['apple', 'bat', 'car', 'door']
result = { [1]: [2] for w in words if len(w) [3] 3 }
Drag options to blanks, or click blank then click option'
Aw.upper()
Blen(w)
C>
Dw
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word instead of uppercase for keys.
Using wrong comparison operators.
Mixing variable names.