Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load data from a spreadsheet file.
AI for Everyone
data = pd.read_excel([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a CSV file name with read_excel causes an error.
Using a JSON or TXT file name with read_excel is incorrect.
✗ Incorrect
The pd.read_excel function loads Excel files, so the file must have an .xlsx extension.
2fill in blank
mediumComplete the code to calculate the average of the 'Sales' column.
AI for Everyone
average_sales = data['Sales'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() returns total, not average.
Using count() returns number of entries, not average.
✗ Incorrect
The mean() function calculates the average value of a column.
3fill in blank
hardFix the error in filtering rows where 'Profit' is greater than 1000.
AI for Everyone
high_profit = data[data['Profit'] [1] 1000]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using = or == causes syntax or logic errors in filtering.
Using < filters the wrong rows.
✗ Incorrect
To filter rows where 'Profit' is greater than 1000, use the > operator.
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 4 letters.
AI for Everyone
lengths = {word: [1] for word in words if len(word) [2] 4} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for dictionary values.
Using < instead of > in the condition.
✗ Incorrect
We want the length of each word (len(word)) and only words longer than 4 letters (> 4).
5fill in blank
hardFill all three blanks to create a dictionary of uppercase words and their counts if count is more than 1.
AI for Everyone
result = [1]: [2] for [3], count in word_counts.items() if count > 1
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using count.upper() causes error because count is a number.
Swapping word and count in the loop variables.
✗ Incorrect
Keys are uppercase words (word.upper()), values are counts, and the loop variable is word.