Question: Which of the following code snippets uses Python to define a function called max_or_min, which takes in a list of numbers and a string as
Which of the following code snippets uses Python to define a function called max_or_min, which takes in a list of numbers and a string as arguments and returns the maximum value in the list if the string is "max", or the minimum value in the list if the string is "min" (The function does not neec to return anything if the string is neither "max" nor "min") Sample input 1:13,8-2,5), "max" Sample output 1:8 Sample input 2:1-4.2.9,-1], "min" Sample output 2:4 function max_or_nin numbers, command) { if(command "max"){ return Math.max(...numbers) } else if(command "in") ( return Math.min(... numbers) } } def max_or_min(numbers, command): if command "max: return max numbers) elif command - "min": return min(numbers) def max_or_mincnumbers, command): if command "max": return numbers.max elif command "min": return numbers.mino def max_or_nin numbers, command) if command "max return numbers.max) etsif command "in" return numbers.inc end end None of these
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
