Complete the code to define the main component responsible for tracking stock levels.
class InventoryManager: def __init__(self): self.stock = [1]
The stock should be stored in a dictionary to map item IDs to their quantities.
Complete the code to add a new item with quantity to the inventory.
def add_item(self, item_id, quantity): if item_id in self.stock: self.stock[item_id] [1] quantity else: self.stock[item_id] = quantity
When the item already exists, increase its quantity by the new amount using '+='.
Fix the error in the code to correctly check if an item is available in stock.
def is_available(self, item_id): return self.stock.get(item_id, 0) [1] 0
To check availability, the quantity must be greater than zero.
Fill both blanks to implement a method that removes a quantity of an item safely.
def remove_item(self, item_id, quantity): if self.stock.get(item_id, 0) [1] quantity: self.stock[item_id] [2] quantity return True return False
Check if stock is enough with '>=' and then subtract quantity with '-='.
Fill all three blanks to create a dictionary comprehension that lists items with low stock.
threshold = {{BLANK_3}}
low_stock = {item: qty for item, qty in self.stock.items() if qty [1] threshold}Use '<' to find items with quantity less than threshold, set threshold to 5 or 10 as needed.
