0
0
Data Analysis Pythondata~10 mins

Boolean filtering 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 filter rows where the 'age' column is greater than 30.

Data Analysis Python
filtered_data = data[data['age'] [1] 30]
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will select ages less than 30.
Using '==' will select only ages exactly 30.
2fill in blank
medium

Complete the code to filter rows where the 'score' column is equal to 100.

Data Analysis Python
perfect_scores = data[data['score'] [1] 100]
Drag options to blanks, or click blank then click option'
A==
B>=
C<
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '==' causes syntax errors.
Using '>=' selects scores 100 or higher, not just 100.
3fill in blank
hard

Fix the error in the code to filter rows where 'height' is less than or equal to 170.

Data Analysis Python
short_people = data[data['height'] [1] 170]
Drag options to blanks, or click blank then click option'
A<
B==
C=>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=>' causes syntax errors.
Using '<' excludes rows where height equals 170.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if the length is greater than 3.

Data Analysis Python
lengths = {word: [1] for word in words if [2]
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(word) > 3
Dword > 3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'word' as the value instead of its length.
Checking 'word > 3' which compares strings to numbers incorrectly.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase words to their scores only if the score is greater than 0.

Data Analysis Python
result = [1]: [2] for [3], [2] in data.items() if [2] > 0
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
Ck
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper() for keys.
Using k as the value instead of v.
Using v as the loop variable instead of k.