Complete the code to show how traditional programming uses rules to get output.
def traditional_programming(input_data): # Use rules to get output if input_data == 'sunny': return [1] else: return 'unknown'
Traditional programming uses fixed rules like returning 'go outside' when input is 'sunny'.
Complete the code to show how machine learning uses data to learn a model.
def machine_learning(data): # Learn a model from data model = [1](data) return model
Machine learning learns a model by training on data using a function like train_model.
Fix the error in the code that predicts output using a learned model.
def predict(model, input_data): # Predict output using model output = model.[1](input_data) return output
The correct method to get predictions from a model is 'predict'. 'train' or 'fit' are for learning, not predicting.
Fill both blanks to create a dictionary comprehension that shows ML learns from data length and compares it.
results = {item: len(item) [1] 3 for item in data if len(item) [2] 2}
The comprehension keeps items with length less than 2 and maps items with length greater than 3.
Fill all three blanks to create a dictionary comprehension that filters and transforms data based on value comparisons.
filtered = [1]: [2] for [1], [2] in dataset.items() if [2] [3] 10}
The comprehension uses 'key' and 'value' to iterate items and filters values greater than 10.
