Bird
Raised Fist0
ML Pythonml~10 mins

ML vs traditional programming in ML Python - Interactive Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to show how traditional programming uses rules to get output.

ML Python
def traditional_programming(input_data):
    # Use rules to get output
    if input_data == 'sunny':
        return [1]
    else:
        return 'unknown'
Drag options to blanks, or click blank then click option'
A'learn model'
B'go outside'
C'train data'
D'predict output'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing options related to machine learning like 'learn model'.
2fill in blank
medium

Complete the code to show how machine learning uses data to learn a model.

ML Python
def machine_learning(data):
    # Learn a model from data
    model = [1](data)
    return model
Drag options to blanks, or click blank then click option'
Atrain_model
Brule_engine
Cfixed_rules
Dmanual_code
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing fixed rules or manual code instead of training.
3fill in blank
hard

Fix the error in the code that predicts output using a learned model.

ML Python
def predict(model, input_data):
    # Predict output using model
    output = model.[1](input_data)
    return output
Drag options to blanks, or click blank then click option'
Afit
Blearn
Ctrain
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' or 'fit' instead of 'predict'.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that shows ML learns from data length and compares it.

ML Python
results = {item: len(item) [1] 3 for item in data if len(item) [2] 2}
Drag options to blanks, or click blank then click option'
A>
B<
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up comparison operators or using equality instead of inequality.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters and transforms data based on value comparisons.

ML Python
filtered = [1]: [2] for [1], [2] in dataset.items() if [2] [3] 10}
Drag options to blanks, or click blank then click option'
Akey
Bvalue
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or wrong comparison operators.

Practice

(1/5)
1. What is the main difference between traditional programming and machine learning?
easy
A. Traditional programming uses fixed rules; machine learning learns from data.
B. Traditional programming learns from data; machine learning uses fixed rules.
C. Both use fixed rules but in different languages.
D. Machine learning does not require any data.

Solution

  1. Step 1: Understand traditional programming

    Traditional programming uses explicit instructions or fixed rules written by humans to solve problems.
  2. Step 2: Understand machine learning

    Machine learning creates models that learn patterns from data examples instead of fixed rules.
  3. Final Answer:

    Traditional programming uses fixed rules; machine learning learns from data. -> Option A
  4. Quick Check:

    Difference = Fixed rules vs learning from data [OK]
Hint: Traditional = rules, ML = learns from examples [OK]
Common Mistakes:
  • Confusing which method uses fixed rules
  • Thinking ML does not need data
  • Assuming both methods are the same
2. Which of the following is the correct way to describe traditional programming?
easy
A. It uses fixed rules written by programmers.
B. It predicts outcomes without any rules.
C. It learns rules from data automatically.
D. It requires no human input at all.

Solution

  1. Step 1: Recall traditional programming definition

    Traditional programming relies on fixed rules explicitly coded by humans.
  2. Step 2: Evaluate options

    Only It uses fixed rules written by programmers. correctly states this; others describe machine learning or incorrect ideas.
  3. Final Answer:

    It uses fixed rules written by programmers. -> Option A
  4. Quick Check:

    Traditional programming = fixed rules [OK]
Hint: Traditional = fixed rules by humans [OK]
Common Mistakes:
  • Mixing up learning from data with fixed rules
  • Thinking traditional programming predicts without rules
  • Believing no human input is needed
3. Consider this code snippet for a traditional program and a machine learning model:
def predict_traditional(x):
    if x > 10:
        return 'High'
    else:
        return 'Low'

# Machine learning model trained on data
model = train_model(data)
prediction = model.predict(15)
What is the key difference in how these two make predictions?
medium
A. Both predict randomly without rules.
B. Both use fixed if-else rules to predict.
C. ML model uses if-else rules; traditional learns from data.
D. Traditional uses fixed if-else rules; ML model predicts based on learned patterns.

Solution

  1. Step 1: Analyze traditional code

    The traditional function uses a fixed if-else rule to decide output based on input.
  2. Step 2: Analyze ML model prediction

    The ML model predicts based on patterns learned from training data, not fixed rules.
  3. Final Answer:

    Traditional uses fixed if-else rules; ML model predicts based on learned patterns. -> Option D
  4. Quick Check:

    Traditional = rules, ML = learned patterns [OK]
Hint: Traditional = if-else rules; ML = learned from data [OK]
Common Mistakes:
  • Assuming ML uses fixed if-else rules
  • Thinking traditional learns from data
  • Believing both predict randomly
4. A programmer wrote this code to classify emails as spam or not:
def classify_email(email):
    if 'free' in email:
        return 'spam'
    else:
        return 'not spam'

# Later, they try to use machine learning but wrote:
model = train_model(data)
result = model.predict('free money')
What is the main problem with this approach?
medium
A. The traditional code is better because it uses fixed rules.
B. The traditional code uses fixed rules; ML needs training data and proper model setup.
C. ML models do not work with text data.
D. The code will run without any issues.

Solution

  1. Step 1: Identify traditional code limitation

    The traditional function uses a simple fixed rule that may miss many spam cases.
  2. Step 2: Understand ML model needs

    ML requires proper training data and model setup before predicting; just calling predict without training causes errors or wrong results.
  3. Final Answer:

    The traditional code uses fixed rules; ML needs training data and proper model setup. -> Option B
  4. Quick Check:

    ML requires training, not just predict call [OK]
Hint: ML needs training data and setup before prediction [OK]
Common Mistakes:
  • Thinking ML works without training
  • Believing fixed rules are always better
  • Ignoring model setup requirements
5. You have a complex problem where rules are hard to write, but you have lots of labeled data. Which approach is best and why? Options: A) Use traditional programming because rules are clearer. B) Use machine learning because it can learn from data patterns. C) Use traditional programming because it needs no data. D) Use neither because both require manual rules.
hard
A. Use traditional programming because rules are clearer.
B. Use traditional programming because it needs no data.
C. Use machine learning because it can learn from data patterns.
D. Use neither because both require manual rules.

Solution

  1. Step 1: Analyze problem complexity and data availability

    When rules are hard to write but labeled data is available, machine learning can find patterns automatically.
  2. Step 2: Compare approaches

    Traditional programming struggles with complex rules; ML excels with data-driven learning.
  3. Final Answer:

    Use machine learning because it can learn from data patterns. -> Option C
  4. Quick Check:

    Complex problem + data = machine learning [OK]
Hint: Complex rules + data = choose machine learning [OK]
Common Mistakes:
  • Choosing traditional programming despite complex rules
  • Ignoring data availability
  • Thinking both require manual rules
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard