0
0
Data Analysis Pythondata~10 mins

Why engineered features improve analysis in Data Analysis Python - Test Your Understanding

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

Complete the code to create a new feature that is the square of the 'age' column.

Data Analysis Python
df['age_squared'] = df['age'] [1] 2
Drag options to blanks, or click blank then click option'
A*
B+
C**
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' adds 2 instead of squaring.
Using '*' multiplies by 2, not square.
Using '//' does integer division.
2fill in blank
medium

Complete the code to filter rows where the new feature 'age_squared' is greater than 1000.

Data Analysis Python
filtered_df = df[df['age_squared'] [1] 1000]
Drag options to blanks, or click blank then click option'
A>
B<
C==
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' selects smaller values.
Using '==' selects only values equal to 1000.
Using '<=' includes values less or equal, not greater.
3fill in blank
hard

Fix the error in the code to create a feature that is the ratio of 'income' to 'age'.

Data Analysis Python
df['income_per_age'] = df['income'] [1] df['age']
Drag options to blanks, or click blank then click option'
A+
B/
C*
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' adds or subtracts instead of dividing.
Using '*' multiplies instead of dividing.
4fill in blank
hard

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

Data Analysis Python
lengths = {word: [1] for word in words if len(word) [2] 4}
Drag options to blanks, or click blank then click option'
Alen(word)
B<=
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' selects words shorter or equal to 4.
Using 'word' as value stores the word, not its length.
5fill in blank
hard

Fill all three blanks to create a dictionary of uppercase words and their lengths for words longer than 3 characters.

Data Analysis Python
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.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using w.lower() for keys instead of uppercase.
Using '<=' instead of '>' for filtering.
Using the word itself as value instead of length.