INTRODUCTION TO FUNCTIONS
In Python, what is a function?
A Python function is a section of code that can be reused in a program.
Which of the following keywords is essential when defining a function?
The def keyword is essential when defining a function. It is placed before a function name to define it.
You want to define a function that performs a status check. Which of the following is a valid header for the function definition?
A valid header for the function definition is def status_check():. Headers should include the def keyword, the name of the function followed by parentheses, and a colon (:).
You are responsible for defining a function alert() that prints out the statement "Security issue detected." Which of the following blocks of code represent the correct indentation for defining and then calling the function? print("Security issue detected.") alert() print("Security issue detected.") alert() (CORRECT) print("Security issue detected") alert() print("Security issue detected") alert()
When defining and then calling a function alert() that prints out the statement "Security issue detected.", the following block of code demonstrates correct indentation: def alert(): print("Security issue detected.") alert( ) The only part that should be indented is the body of the function definition. In this case, the body is the line with the print() function.
Ready to test your recall?
In Python, what is a function?
How confident are you in this answer?