Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the total sales using sum.
Data Analysis Python
total_sales = df['sales'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean() instead of sum() which calculates average.
Using count() which counts entries, not sums values.
✗ Incorrect
The sum() function adds all values in the 'sales' column to get the total sales.
2fill in blank
mediumComplete the code to find the average age using mean.
Data Analysis Python
average_age = df['age'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() which adds values instead of averaging.
Using count() which counts entries, not averages.
✗ Incorrect
The mean() function calculates the average of the 'age' column.
3fill in blank
hardFix the error in the code to count the number of entries in the 'product' column.
Data Analysis Python
product_count = df['product'].[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum() which adds values instead of counting.
Using mean() which calculates average, not count.
✗ Incorrect
The count() function counts the number of non-missing entries in the 'product' column.
4fill in blank
hardFill both blanks to create a dictionary with total and average sales.
Data Analysis Python
sales_summary = {'total': df['sales'].[1](), 'average': df['sales'].[2]()} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sum and mean functions.
Using count instead of sum or mean.
✗ Incorrect
Use sum() to get total sales and mean() to get average sales.
5fill in blank
hardFill all three blanks to create a dictionary with count, total, and average of 'quantity'.
Data Analysis Python
quantity_stats = {'count': df['quantity'].[1](), 'total': df['quantity'].[2](), 'average': df['quantity'].[3]()} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mean for count or sum.
Mixing order of functions.
✗ Incorrect
Use count() to count entries, sum() for total quantity, and mean() for average quantity.