Complete the code to define a decision table as a list of dictionaries.
decision_table = [[1]]The decision table is best represented as a list of dictionaries where each dictionary maps conditions to actions.
Complete the code to check if a condition matches in the decision table.
if rule['condition'] == [1]: execute_action(rule['action'])
We compare the condition value in the rule to the string 'A' to find matching rules.
Fix the error in the code to iterate over all rules in the decision table.
for rule in [1]: print(rule['action'])
The decision table is a list named 'decision_table'. We iterate over it directly without parentheses or hyphens.
Fill both blanks to create a decision table filtering rules with condition 'B'.
filtered_rules = [rule for rule in decision_table if rule[[1]] == [2]]
We filter rules where the 'condition' key equals 'B'.
Fill all three blanks to create a decision table dictionary comprehension with conditions and actions.
decision_dict = { [1]: [2] for rule in decision_table if rule[[3]] == 'C'}The dictionary comprehension uses curly braces to create a dict with condition keys and action values, filtering rules where condition is 'C'.