WorksheetsFunctions in Python
Total questions: 15
Worksheet time: 14mins
Which of the following keywords marks the begining of the function block?
Func
define
def
function
Which of the following pertains to a piece of code that can take inputs to perform a specific task?
Arguments
Functions
Parameters
Loops
When defining a function, the definition must occur before it is called.
TRUE
FALSE
The variable listed inside the parentheses in the function definition is called a(n) (a) , while the value that is sent to the function when it is called is a(n) (b) .
Which of the following describe what parameters are function? (Select 2)
input value to a function for the function’s execution
a variable used to send information to a function
the name of the function
the name of the main program calling the function
Which of the following symbols always comes after a function code block?
;
]
:
#
Which of the following is TRUE about the given function? (Select 3)
checkOdd() function will not run because it has 2 return values
num is a parameter of the function checkOdd()
The value of num will determine the return value of the checkOdd()
The checkOdd() function has two possible parameters.
checkOdd() will either return a True or False value.
Parameters are the (a) used in the function definition.
In Python, if no value is provided in the function call, the argument takes (a) value.
Complete the syntax below to place on the "missing code" area on Line 4. The code must print the sum of 10 and 20:
(a) ( (b) ( (c) , 20))
Complete the code block below to create a function with the function name as myFunction:
(a) (b) (c) (d)
Fill-in the blanks on the syntax on Line 1 to output the phrase "Hello, Cedric."
def (a) ( (b) ):
Complete the code on the attached image by dragging the handlers below to appropriate areas given below. The desired output is 7.
Line 2: (a) a+b
Line 4: (b) = 4
Line 6: print( (c) (num1, (d) ))
Complete the syntax below to create a Python Function with name "factorial" and parameter num.
(a) (b) ( (c) ):
The function checkOdd() determines if a given number is odd or even by returning True or False, respectively. Complete the code on the image by dragging and dropping the handlers to the correct spots below. The desired output is to display "a is an odd number" if it is odd, and "a is an even number" if otherwise.
Line 3: return (a)
Line 5: return (b)
Line 8: if( (c) ( (d) )):
