Question: EASY PYTHON QUESTION SET: 1a) Which statement should be added or modified to remove the possibility of a run-time error in this code snippet? 1:
EASY PYTHON QUESTION SET:
1a) Which statement should be added or modified to remove the possibility of a run-time error in this code snippet?
1: def floorDivision(value1, value2) : 2: return value1 // value2
1b) The following function is supposed to return -1 when x is negative, +1 when x is positive, or 0 if x is zero. What, if anything, is wrong with the function?
def plusMinusZero(x) : if x == 0: return 0 elif x < 0: return -1 elif x > 0: return 1
1c) Which statement causes the following function to exit immediately?
def mystery(num1, num2) : result = num1 ** num2 return result mystery(10, 2)
1d) What are the arguments (actual parameters) in this program?
def squareArea(sideLength) : return sideLength ** 2 a = squareArea(4)
1e) Given the following code snippet, what is considered a parameter variable(s)?
def mystery(num1, num2) : result = num1 ** num2 return result mystery(10, 2)
1f)
Consider the following function.
def factorial(n) : result = 1 for i in range(1, n + 1) : result = result * i return result
What is the parameter variable for this function?
| factorial |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
