For each of the following statements, determine whether it is true for function
ID: 3916862 • Letter: F
Question
For each of the following statements, determine whether it is true for function definitions, function calls or both.
The parameters are separated by commas and enclosed in parentheses.
[ Choose ] Function Definition Both Function Call
It ends with a colon (:) and is always follwed by a an indented block of statements, just like a loop or if-statement.
[ Choose ] Function Definition Both Function Call
It can be used as part of an expression.
[ Choose ] Function Definition Both Function Call
It causes the statements in the body of the function to be executed.
[ Choose ] Function Definition Both Function Call
It starts with the "def" keyword.
options are function definition, both, function call
Explanation / Answer
1. The parameters are separated by commas and enclosed in parentheses.:- Both function call and definition
Example:-
# Function definition is here
def printinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now you can call printinfo function
printinfo( "aditi",23 )
2. It ends with a colon (:) and is always follwed by a an indented block of statements, just like a loop or if-statement.:- Function Definition
Example:-
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
3. It can be used as part of an expression.:- Function call
Example:-
Function calls are expressions, so you can use them in statements such as print or =:
x = len('hello') # The expression evaluates to 5
print hex(48) # The expression evaluates to '0x30'
4. It causes the statements in the body of the function to be executed. :- Function call
Example:-
//Function Definition
def greet(name, msg ):
print("Hello",name + ', ' + msg) // statements in function body
//Function call
greet("Bruce",msg = "How do you do?")
Whenever we call the function greet the message will be printed.
5. It starts with the "def" keyword.:- Function Definition
Example:-
//Function Definition
def greet(name, msg ):
print("Hello",name + ', ' + msg)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.