Computer Science
What will the following function return?
def addEm(x, y, z):
print(x + y + z)
x = y = z = 10
Python Functions
3 Likes
Answer
The function addEm
will return None
. The provided function addEm
takes three parameters: x, y, and z. It calculates their sum, which is 30, and then prints it. However, it doesn't explicitly return any value. In Python, when a function doesn't have a return statement, it implicitly returns None
.
Answered By
3 Likes
Related Questions
Write the term suitable for the following descriptions:
(a) A name inside the parentheses of a function header that can receive a value.
(b) An argument passed to a specific parameter using the parameter name.
(c) A value passed to a function parameter.
(d) A value assigned to a parameter name in the function call.
(e) A name defined outside all function definitions.
(f) A variable created inside a function body.
Consider the following code and write the flow of execution for this. Line numbers have been given for your reference.
1. def power(b, p): 2. y = b ** p 3. return y 4. 5. def calcSquare(x): 6. a = power(x, 2) 7. return a 8. 9. n = 5 10. result = calcSquare(n) 11. print(result)
What will be the output displayed when addEM() is called/executed?
def addEM(x, y, z): return x + y + z x=y=z=20
What are variables ? How are they important for a program ?