What normally happens when Python executes a function definition such as def greet(): print("Hello!")?
06. Procedures and Functions Online Quiz Questions
Use this free practice quiz with 20 questions to review 06. Procedures and Functions, test your knowledge, and prepare for your next test or exam.
True or false: In def greet_person(name): ..., name is a parameter, while in greet_person("Maya"), "Maya" is an argument.
- A
True
- B
False
What programming term names the variable in a function definition that receives a value supplied by the caller?
Complete the statement: If a Python function reaches the end without returning a value, it returns .
In the function def square(number): ..., which statement makes the squared value available to the code that called the function?
- A
print(number * number) - B
result = number * number - C
return number * number - D
number = number * number
Given def power(base, exponent=2): return base ** exponent, select all correct statements.
- A
power(5)returns 25. - B
power(5)returns 125. - C
power(5, 3)returns 125. - D
power(5, 3)returns 25.
True or false: If a function executes a return statement, a later statement in that same function body will still execute normally.
- A
True
- B
False
In the material's abstraction example, what is the exact function name that lets a caller test whether a number is divisible by 2?
Complete the statement: A function that modifies the list supplied by its caller produces a .
Which statement best describes the variable tax created inside calculate_total(price, tax_rate)?
- A
A variable created inside a function is automatically global.
- B
A variable created inside a function is usually local to that function call.
- C
A local variable can be accessed from any function in the program.
- D
A local variable exists only while the program is being defined.
In the decomposition example with weighted_score, letter_grade, and report_result, select all accurate descriptions of the functions' responsibilities.
- A
weighted_scorecalculates the weighted numerical score. - B
letter_gradecalculates the weighted numerical score. - C
letter_gradedetermines the letter category from a score. - D
report_resultcoordinates the smaller operations.
Explain what happens when this code runs, and why: def double_and_print(number): print(number * 2) followed by result = double_and_print(4).
Which design choice best makes a function's dependencies visible and supports testing?
- A
Pass required data as parameters and return results explicitly.
- B
Use global variables so every function can access the same data.
- C
Put all calculations into one large function to avoid communication between functions.
- D
Hide required inputs in unrelated local variables.
Consider this Python code: def greet_person(name): print("Hello, " + name + "!"); the function is called with greet_person("Maya"). Which statement correctly identifies the parameter and the argument?
- A
nameis the argument and"Maya"is the parameter. - B
nameis the parameter and"Maya"is the argument. - C
Both
nameand"Maya"are parameters. - D
Both
nameand"Maya"are arguments.
What happens when this function is called as result = choose()?
def choose(): return 7 print(9)
- A
The function prints 7 and then returns
None. - B
The function prints both 7 and 9.
- C
The function returns 7 and does not print 9.
- D
The function returns 9 because it is the last expression.
In the following code, what is true about tax after amount = calculate_total(100, 0.08)?
def calculate_total(price, tax_rate): tax = price * tax_rate total = price + tax return total
- A
taxis local tocalculate_totaland is not directly accessible outside it. - B
taxis global because it is used in an arithmetic expression. - C
taxis automatically returned along withtotal. - D
taxcan be accessed outside the function because all Python variables are global.
How should this function be classified?
def add_score(scores, new_score): scores.append(new_score)
- A
It is pure because it accepts a list parameter.
- B
It is pure because it performs only one operation.
- C
It has no effect because it does not return a value.
- D
It has a side effect because it modifies the caller's list.
True or false: In Python, defining a function normally executes its body immediately.
- A
True
- B
False
The function average(first, second, third) returns (first + second + third) / 3. What value does average(80, 90, 100) return? Enter the numerical average as a whole number.
What is the programming term for dividing a large problem into smaller subproblems, with each subproblem potentially implemented as a focused function? Enter the single programming term.
Related study packs and tools
AP Computer Science A: Integrated Java Problem Solving
A practical review of the integrated Java skills, debugging habits, algorithm reasoning, and free-response strategies needed for AP Computer Science A.
Fault Tolerance and Redundant Systems
A progressive guide to designing, operating, and testing systems that continue useful service despite component faults, overload, data loss, and recovery challenges.
How the Internet Works
A medium-difficulty quiz on how independently operated networks, protocols, addresses, naming systems, transport services, and routing mechanisms work together to form the Internet.
Java ArrayList and Collections: Operations, Traversals, and Algorithms
Learn how to create, modify, traverse, and analyze Java lists with ArrayList, wrapper types, standard algorithms, and the Collections utility class for AP Computer Science A.
Java Boolean Logic and Selection
Build a clear understanding of Java Boolean expressions, logical operators, selection statements, nested branching, equivalent logic, and systematic code tracing for AP Computer Science A.
Java Foundations and Program Design
A practical introduction to Java program structure, data types, operators, input and output, problem-solving strategy, testing, and debugging for AP Computer Science A.
Java Inheritance and Polymorphism
A practical guide to Java inheritance, constructor chaining, method overriding, polymorphism, access control, and object behavior for tracing and writing AP Computer Science A programs.
Java Objects, Classes, and the String API
A focused guide to Java classes, object references, constructors, methods, strings, wrapper classes, and API usage for AP Computer Science A.
Java Primitive Types and Expression Evaluation
A focused guide to Java primitive types, expression evaluation, numeric conversion, floating-point behavior, integer overflow, and common methods in the Math class for AP Computer Science A.
Java Primitive Types and Expressions
A focused review of Java primitive types, expression evaluation, numeric conversion, arithmetic behavior, Math methods, randomness, and tracing techniques for AP Computer Science A.
Packets, Links, and Network Performance
A progressive guide to how packet-switched networks encapsulate data, move it across links, and manage delay, throughput, queues, and congestion.
Parallel and Distributed Computing
A structured guide to designing parallel and distributed systems through decomposition, communication, coordination, state management, scalability, and fault tolerance.