Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a CSV file into a DataFrame using pandas.
ML Python
import pandas as pd df = pd.read_csv([1])
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name.
Using wrong function names like read.csv.
✗ Incorrect
The file path must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to show the first 5 rows of the DataFrame.
ML Python
print(df.[1]())
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail() which shows last rows.
Using non-existent methods like show() or top().
✗ Incorrect
The head() method shows the first 5 rows by default.
3fill in blank
hardFix the error in the code to get summary statistics of the DataFrame.
ML Python
summary = df.[1]()Attempts:
3 left
💡 Hint
Common Mistakes
Using info() which shows data types, not statistics.
Using non-existent methods like summary() or stats().
✗ Incorrect
The describe() method returns summary statistics like mean and std.
4fill in blank
hardFill both blanks to create a dictionary of word lengths for words longer than 3 letters.
ML Python
lengths = {word: [1] for word in words if len(word) [2] 3}Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the condition.
Using 'word' instead of 'len(word)' for the dictionary value.
✗ Incorrect
We want the length of each word (len(word)) and only words longer than 3 (>) are included.
5fill in blank
hardFill all three blanks to create a filtered dictionary with uppercase keys and values greater than 0.
ML Python
result = [1]: [2] for k, v in data.items() if v [3] 0 }
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() for keys.
Using '<' instead of '>' in the condition.
Using k instead of v for values.
✗ Incorrect
Keys are converted to uppercase with k.upper(), values are v, and we filter values greater than 0 with '>'.
