Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add two pandas Series s1 and s2.
Data Analysis Python
result = s1 [1] s2 Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' causes subtraction.
Using '*' or '/' will multiply or divide instead of adding.
✗ Incorrect
Adding two Series uses the + operator to sum values by index.
2fill in blank
mediumComplete the code to subtract Series s2 from s1.
Data Analysis Python
result = s1 [1] s2 Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' adds instead of subtracting.
Using '*' or '/' changes the operation to multiply or divide.
✗ Incorrect
Subtracting s2 from s1 uses the '-' operator.
3fill in blank
hardFix the error in the code to multiply two Series s1 and s2 element-wise.
Data Analysis Python
result = s1 [1] s2 Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' changes the operation to addition or subtraction.
Using '/' divides instead of multiplying.
✗ Incorrect
Element-wise multiplication uses the '*' operator between Series.
4fill in blank
hardFill both blanks to create a new Series with squares of values from s for indices where values are greater than 3.
Data Analysis Python
result = {word: s[word][1]2 for word in s.index if s[word] [2] 3} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' instead of '**' does multiplication, not power.
Using '<' instead of '>' filters wrong values.
✗ Incorrect
Use '**' to square the value and '>' to filter values greater than 3.
5fill in blank
hardFill all three blanks to create a dictionary of index labels in uppercase with their values, filtering values less than 5.
Data Analysis Python
result = [1]: [2] for [3], val in s.items() if val < 5}}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using item instead of idx causes undefined variable error.
Using val as key or idx.upper() as loop variable causes errors.
✗ Incorrect
Use idx.upper() for keys, val for values, and idx as the loop variable for index labels.