In: Computer Science
The following is an incomplete function definition of the void function named SomeFun:
________________________________ if (n1 > 0): index = n2 while index < n3: print(index, end=" ") index += n1 else: print("step should be positive.")
The function SomeFun takes 3 numbers as parameters
and tries to print numbers
between the first and the second parameters with the increment of
the third parameter.
For example function call SomeFun(1, 10, 2) generates
1 3 5 7 9
The function call SomeFun(10, 1, -2) generates
step should be positive.
Complete the function definition by writing the function
header.
The missing function header should be:
def SomeFun(n2, n3, n1):
Explanation:
This is because , first of all, def keyword is used to define a function and inside the brackets present after that, there comes the parameters passed to the function.
In this case, the parameters passed are n1, n2 and n3.
Now, the order of the parameters should be decided by looking at the definition of the function given above.
It is clearly visible that if n1 is less than or equal to 0, it prints that Step should be positive. So the step is n1 variable.
And while Calling the function, step is passed as the last parameter, so n1 should be the last parameter of the function.
Now n2 is the starting point of the range and n3 is the ending point as index < n3 is used in the while loop.
So, while Calling the function, starting of the range is passed as the first parameter, that is n2 and second parameter should be n3.
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!