A. KeyError if item_feats lacks a category; fix by iterating item_feats keys
B. SyntaxError due to missing colon; fix by adding colon after for loop
C. TypeError because score is int; fix by converting score to float
D. No error; code runs correctly
Solution
Step 1: Identify potential KeyError
The loop uses keys from user_prefs but accesses item_feats; if item_feats misses a key, error occurs.
Step 2: Fix iteration to avoid missing keys
Iterate over keys in item_feats or check key existence before access.
Final Answer:
KeyError if item_feats lacks a category; fix by iterating item_feats keys -> Option A
Quick Check:
Key mismatch causes error [OK]
Hint: Check keys exist before accessing dict values [OK]
Common Mistakes:
Assuming all keys match in both dicts
Ignoring possible KeyError exceptions
Confusing syntax errors with runtime errors
5. A streaming service wants to improve engagement by recommending movies. They have user watch history and movie genres. Which approach best uses machine learning to drive engagement?
hard
A. Display only movies with the highest global ratings ignoring user data
B. Recommend only the newest movies regardless of user preferences
C. Build a model that predicts user ratings for unseen movies based on past watched genres
D. Show random movies from the entire catalog to all users
Solution
Step 1: Understand personalized recommendations
Using user watch history and genres helps predict what each user likes.
Step 2: Evaluate options
Build a model that predicts user ratings for unseen movies based on past watched genres uses machine learning to personalize, increasing engagement; others ignore personalization.
Final Answer:
Build a model that predicts user ratings for unseen movies based on past watched genres -> Option C
Quick Check:
Personalized prediction = better engagement [OK]
Hint: Use user history to predict preferences for recommendations [OK]
Common Mistakes:
Ignoring user preferences in recommendations
Assuming newest or highest rated always engage users
Confusing random recommendations with personalized ones
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.