Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the total cost by multiplying unit cost and quantity.
Agentic AI
total_cost = unit_cost [1] quantity Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of multiplication
Using division or subtraction by mistake
✗ Incorrect
Multiplying unit cost by quantity gives the total cost.
2fill in blank
mediumComplete the code to calculate the average cost from a list of costs.
Agentic AI
average_cost = sum(costs) [1] len(costs)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multiplication or addition instead of division
✗ Incorrect
Average is total sum divided by number of items.
3fill in blank
hardFix the error in the code to select the minimum cost from a list.
Agentic AI
min_cost = [1](costs) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using max instead of min
Using sum or len which do not find minimum
✗ Incorrect
The min function returns the smallest value in a list.
4fill in blank
hardFill both blanks to create a dictionary of costs for items with cost greater than 50.
Agentic AI
high_cost_items = {item: [1] for item, [2] in costs.items() if [1] > 50} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using item instead of cost for values
Using costs instead of cost in loop
✗ Incorrect
Use cost as the value and cost as the variable for dictionary values.
5fill in blank
hardFill all three blanks to filter and create a dictionary of items with cost less than 100.
Agentic AI
filtered_costs = { [1]: [2] for [3], cost in costs.items() if cost < 100 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys and values
Using wrong variable names in loop
✗ Incorrect
The dictionary keys are item, values are cost, and the loop variable is item.
