0
0
ML Pythonprogramming~20 mins

ML vs traditional programming in ML Python - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ML vs Traditional Programming Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Key difference between ML and traditional programming

Which statement best describes the main difference between machine learning and traditional programming?

AMachine learning does not need any input data to make decisions, unlike traditional programming.
BMachine learning always requires less data than traditional programming.
CMachine learning learns patterns from data, while traditional programming uses explicit rules written by humans.
DTraditional programming can automatically improve itself without human input, unlike machine learning.
Attempts:
2 left
Predict Output
intermediate
2:00remaining
Output of a simple ML prediction vs rule-based code

Given the following code snippets, what is the output of the machine learning model prediction compared to the traditional rule-based function?

ML Python
def rule_based(x):
    if x > 5:
        return 'High'
    else:
        return 'Low'

class SimpleModel:
    def predict(self, x):
        return 'High' if x > 3 else 'Low'

input_value = 4
print(rule_based(input_value))
model = SimpleModel()
print(model.predict(input_value))
ALow\nHigh
BLow\nLow
CHigh\nLow
DHigh\nHigh
Attempts:
2 left
Model Choice
advanced
2:00remaining
Choosing between ML and traditional programming for a task

You want to build a system that detects spam emails. Which approach is more suitable and why?

AUse machine learning because it can learn from examples and adapt to new spam types.
BUse traditional programming with fixed rules because spam patterns never change.
CUse traditional programming because it requires large amounts of labeled data.
DUse machine learning because it does not need any data to work.
Attempts:
2 left
Metrics
advanced
2:00remaining
Evaluating ML vs traditional programming accuracy

You test a traditional program and a machine learning model on 100 samples. The traditional program correctly classifies 80 samples, and the ML model correctly classifies 90 samples. What are their accuracies?

ATraditional: 0.8%, ML: 0.9%
BTraditional: 80%, ML: 90%
CTraditional: 90%, ML: 80%
DTraditional: 8%, ML: 9%
Attempts:
2 left
🔧 Debug
expert
2:00remaining
Why does this ML model fail but traditional code works?

Given the code below, why does the machine learning model prediction raise an error while the traditional function works fine?

ML Python
def traditional_func(x):
    return 'Positive' if x > '0' else 'Non-positive'

class MLModel:
    def predict(self, x):
        return x > 0

input_value = '5'
print(traditional_func(input_value))
model = MLModel()
print(model.predict(input_value))
AThe ML model fails because it returns a string instead of a boolean.
BThe traditional function fails because it cannot handle strings.
CBoth functions work fine with string input.
DThe ML model fails because it tries to compare a string with an integer, causing a TypeError.
Attempts:
2 left