0
0
Data Analysis Pythondata~10 mins

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

Data Analysis Python
filtered = df[df['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 wrong rows.
Using '==' will select only rows where age equals 30.
2fill in blank
medium

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

Data Analysis Python
perfect_scores = df[df['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 rows where score is not 100.
3fill in blank
hard

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

Data Analysis Python
short_people = df[df['height'] [1] 170]
Drag options to blanks, or click blank then click option'
A<=
B<
C=>
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=>' is invalid syntax.
Using '<' excludes values equal to 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
{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 value instead of length.
Using 'word > 3' which compares string to number.
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 50.

Data Analysis Python
{ [1]: [2] for word, score in data.items() if [3] }
Drag options to blanks, or click blank then click option'
Aword.upper()
Bscore
Cscore > 50
Dword.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using word.lower() instead of word.upper().
Not filtering scores correctly.