No student devices needed. Know more
26 questions
Which type of function is provided by the Python language?
Anonymous Functions
User-defined Functions
Object Functions
Built-in functions
Which of the following is NOT a valid function invocation?
print("Bla")
max(3; 4)
pow(5, 6)
input()
Which of the following is NOT a valid function invocation?
print "Bla"
max(3, 4)
len("ABC123")
print()
True or False:
When a function returns a value, we can use it as an argument to another function, like this:
max(1, pow(2, n))
True
False
True or False:
Methods need to be called in reference to an object, like this:
leonardo.move_forward(10)
True
False
Which is the correct way to invoke the "title" method on the string stored in variable "name".
name(title())
title.name()
name.title()
title(name())
Which module provides functions for generating random values?
random
randint
rand
math
Which function from the random module can be used to generate a random integer?
random
choice
uniform
randint
Which function from the random module can be used to generate a random floating point number?
random
choice
uniform
randint
Which function call will return a random value between (and including) 1 and 20?
randint(0, 20)
randint(1, 20)
randint(0, 21)
randint(1, 21)
Which function call will return a random float between (and including) 1 and 20?
uniform(1, 20)
randint(1, 20)
uniform(0, 21)
randint(0, 21)
Which function call will return a random value between (but not including) 1 and 20?
randint(2, 19)
randint(1, 20)
randint(1, 19)
randint(2, 20)
Which keyword is used at the very beginning of a function definition?
function
define
def
func
True or False:
The code stored inside of a function needs to be indented.
True
False
Which of the following is the correct way to write the first line of the function definition for a function called "start_game"?
def start_game
def start_game ():
def start_game ()
def start_game:
True or False:
If a function does not have any parameters, then you don't need the brackets on the line with "def".
True
False
True or False:
You can only invoke a user-defined function once in your program.
True
False
True or False:
It doesn't matter which order you put parameters in your function definition.
True
False
Which of the following is the correct way to start defining a function called "calculate_area" that takes two arguments: the base an height of a triangle
The function "welcome" is defined as in the picture. What will be printed when this is called:
welcome("Joe", "Smith")
Hello Joe Smith
Hello Smith Joe
Hello Joe Joe
Hello Smith Smith
The function "welcome" is defined as in the picture. What will be printed when this is called:
welcome("Joe")
Hello Joe
Hello Joe Joe
Hello Joe None
*** ERROR ***
When defining a function, what do we call the variables that are put in the brackets as placeholders for the arguments?
arguments
parameters
inputs
placeholders
True or False:
A user-defined function must have parameters.
True
False
The "calculate_area" function is defined in the picture.
What is the correct way to invoke (call) this function to find the area of a triangle with base length 8 and height 10?
calculate_area(8, 10)
calculate_area(8)(10)
calculate_area(10, 8)
calculate_area(10)(8)
The "calculate_area" function is defined in the picture.
Which of the following is NOT a correct way to invoke (call) this function?
calculate_area(1.2, 3.4)
calculate_area(8, 10)
calculate_area(12345, 98765)
calculate_area(7.34; 9.12)
Which type of function is created by the programmer for use later in the program.
Anonymous Functions
User-defined Functions
Object Functions
Built-in functions
Explore all questions with a free account