(Solved) : Consider Following Function Def Find Difference Data Largest Data O Smallestdata 0 X Data Q34283376 . . .
In Python,
![Consider the following function: def find difference(data): largest-data[O] smallestdata 0 for x in data: if largest <x: Largest -x if smallest > x: smallestx return Largest smaLLest Modify the function so it will return* the total number of statements that are executed inside the function. Do not count any additional statements that you add to the code when you modify it The for loop is counted in the same way as the while loop. The loop header is counted once for each iteration through the loop 1 additional time (i.e. a for loop that executes 4 times will count the loop header for x in data: 5 times Checking an IF condition is counted as 1 statement, and then each statement in the loop body is counted when it is executed Your function should return a tuple, where the first value is the return value of the original function (i.e., largest- smallest), and the second value is the count of the number of statements executed. You could call the function using difference, countfind_difference([1, 2, 3]) where count is an integer value For example: Test Result result, count - find difference(01]) print(fNumber of statements: {count} Number of statements: 7](https://media.cheggcdn.com/media%2F8eb%2F8ebf018e-aee4-4c4f-9c46-4c4fc1875165%2FphpN2Y5sa.png)
Consider the following function: def find difference(data): largest-data[O] smallestdata 0 for x in data: if largest <x: Largest -x if smallest > x: smallestx return Largest smaLLest Modify the function so it will “return* the total number of statements that are executed inside the function. Do not count any additional statements that you add to the code when you modify it The for loop is counted in the same way as the while loop. The loop header is counted once for each iteration through the loop 1 additional time (i.e. a for loop that executes 4 times will count the loop header “for x in data:” 5 times Checking an IF condition is counted as 1 statement, and then each statement in the loop body is counted when it is executed Your function should return a tuple, where the first value is the return value of the original function (i.e., largest- smallest), and the second value is the count of the number of statements executed. You could call the function using difference, countfind_difference([1, 2, 3]) where count is an integer value For example: Test Result result, count – find difference(01]) print(f’Number of statements: {count}’ Number of statements: 7 Show transcribed image text
Expert Answer
Answer to Consider Following Function Def Find Difference Data Largest Data O Smallestdata 0 X Data Q34283376 . . .
OR