Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python programming debug question def get_sum_metrics(predictions, metrics=[]): for i in range(3): metrics.append(lambda x: x + i) sum_metrics = 0 for metric in metrics: sum_metrics +=

python programming debug question

def get_sum_metrics(predictions, metrics=[]):

for i in range(3):

metrics.append(lambda x: x + i)

sum_metrics = 0

for metric in metrics:

sum_metrics += metric(predictions)

return sum_metrics

def main():

print(get_sum_metrics(0)) # Should be (0 + 0) + (0 + 1) + (0 + 2) = 3

print(get_sum_metrics(1)) # Should be (1 + 0) + (1 + 1) + (1 + 2) = 6

print(get_sum_metrics(2)) # Should be (2 + 0) + (2 + 1) + (2 + 2) = 9

print(get_sum_metrics(3, [lambda x: x])) # Should be (3) + (3 + 0) + (3 + 1) + (3 + 2) = 15

print(get_sum_metrics(0)) # Should be (0 + 0) + (0 + 1) + (0 + 2) = 3

print(get_sum_metrics(1)) # Should be (1 + 0) + (1 + 1) + (1 + 2) = 6

print(get_sum_metrics(2)) # Should be (2 + 0) + (2 + 1) + (2 + 2) = 9

if __name__ == "__main__":

main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions