🌍 All Study Guides📊 Dashboard📰 Blog💡 About
Google Cybersecurity Professional Certificate • STUDY MODE

INTRODUCTION TO FUNCTIONS

QUESTION 1 OF 4

In Python, what is a function?

A
A section of code that contains an iterative statement
B
A section of code that can be reused in a programCorrect Answer
C
A section of code that exists directly in Python
D
A section of code that contains a conditional
Explanation:

A Python function is a section of code that can be reused in a program.

QUESTION 2 OF 4

Which of the following keywords is essential when defining a function?

A
for
B
while
C
if
D
defCorrect Answer
Explanation:

The def keyword is essential when defining a function. It is placed before a function name to define it.

QUESTION 3 OF 4

You want to define a function that performs a status check. Which of the following is a valid header for the function definition?

A
def status_check
B
def status_check():Correct Answer
C
def status_check()
D
def status_check:
Explanation:

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 (:).

QUESTION 4 OF 4

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()

A
def alert():
B
def alert():
C
def alert():
D
def alert():
Explanation:

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?

A
A section of code that contains an iterative statement
B
A section of code that can be reused in a program
C
A section of code that exists directly in Python
D
A section of code that contains a conditional

How confident are you in this answer?