Python Chapter 4 Review
In Python you can have a list of variables on the left side of the argument operator. (TRUE OR FALSE)
True
What is a group of statements that exists within a program for the purpose of performing a specific task? A) subtask B) subprocess C) process D) function
D) function
The Python Library functions that are built into the Python ______ can be used by simply calling the required function. A) Linker B) compiler C) code D) interpreter
D) interpreter
What will display after the following code is executed? def main(): print("The answer is", magic(5)) def magic(num): answer = num + 2 * 10 return answer if ___ name _____== '____main____': A) 25 B) 70 C) 100 D) the statement will cause a syntax error
A) 25
What will be the output after the following code is executed? def pass_it(x,y) z = x + "," + y return(z) name2 = "Julian" name1 - "Smith" fullname = pass_it(name1, name2) print(fullname) A)Smith, Julian B)Julian Smith C)Smith Julian D)Julian, Smith
A) Smith, Julian
A _______ variable is accessible to all the functions in a program file A) global B) keyword C) string D) local
A) global
A(n) _________ is any piece of data tha is passed into a function when the function is called. A)parameter B) named constant C) global variable D)argument
A) parameter
The _______ of a local variable is the function in which that variable is created. A) scope B) definition C) space D) global reach
A) scope
A value-returning function is. A) a single statement that performs a specific task B) a function that will return a value back to the part of the program that called it C) Called when you want the function to stop D) a function that receives a value when called
B) a function that will return a value back to the part of the program that called it
Which of the following functions returns the largest integer that is less than or equal to its argument? A) ceil B) floor C) lesser D) greater
B) floor
The first line in a function definition is known as the function A) return B) header C) block D) parameter
B) header
Which of the following statements causes the interpreter to load the contents of the random module into memory? A) load random B) Import random C) Download random C) upload random
B) import random
The Python standard library's ______ module contains numerous functions that can be used in mathematical calculations A) number B) math C) random D) string
B) math
What does the following statement mean? num1, num2 = get_ num() A) the function get_num() is expected to return one value and assign it to num1 and num2 B) The function get_num() is expected to return a value for num1 and for num2. C) the funciton get_num() will receive the values stored in num1 and num2. D) This statement will cause a syntax error.
B) the function get_num() is expected to return a value for num1 and for num2.
What will be the output after the following code is executed? def pass_it(x,y): z = x, ",", y num1 = 4 num2 = 8 answer = pass_it(num1, num2) print(answer) A) 8,4 B)48 C)None D)4, 8
C) None
A(n) _________ is any piece of data that is passed into a function when the function is called. A) local variable B) global Variable C) argument D) parameter
C) argument
A set of statements that belong together as a group and contribute to the function definition is known as a A) parameter B) header C) block D) return
C) block
When a function is called by its name during the execution of a program, then it is A) located B) defined C) executed D) exported
C) executed
In a value-returning function, the value of the expression that follows the keyword ________ will be sent back to the part of the program that called the function A) result B) def C) return D) sent
C) return
Python comes with _____ functions that have been already prewritten for the programmer. A) library B) key C) standard D) custom
C) standard
A __________ variable is created inside a function A) global B) named constant C) constant D) local
D) local
Which of the following statements causes the interpreter to load the contents of the random module into memory? A) random(1, 50) = number B) number = random(range(1, 50)) C) randint(1,50) = number D) number = random.randint(1,50))
D) number = random.randint(1,50))
A function definition specifies what a function does and causes the function to execute. (TRUE OR FALSE)
False
A local variable can be accessed from anywhere in the program.(TRUE OR FALSE)
False
One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure. (TRUE OR FALSE)
False
The math function atan(x) returns on tangent of x in radians.(TRUE OR FALSE)
False
The pass keyword is used to pass arguments to a function. (TRUE OR FALSE)
False
Unlike other languages, in Python, the number of values a function can return is limited to one. (TRUE OR FALSE)
False
Different functions can have local variables with the same names.(TRUE OR FALSE)
TRUE
A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that is called it. (TRUE OR FALSE)
True
Python allows you to pass multiple arguments to a function.(TRUE OR FALSE)
True
Python function names follow the same rules as those for naming variables. (TRUE OR FALSE)
True
The function header marks the beginning of the function definition. (TRUE OR FALSE)
True
The math function ceil(x) returns the smallest integer that is greater than or equal to x. (TRUE OR FALSE)
True
The randrrange function returns a randomly selected value from a specific sequence of numbers. (TRUE OR FALSE)
True
To assign a value to a global variable in a function, the global variable must be first declared in the function(TRUE OR FALSE)
True