liveBook · Manning

Call

As explained in Learn AI-Assisted Python Programming, Second Edition

A function call is an invocation that transfers execution to a function and resumes at the code following the invocation when the function returns.

A function call invokes a function with specific arguments. The function runs, returns a result, and resumes execution at the line following the call. Parentheses immediately after a function name usually mark the call. section 3.1.2 section 3.5

Use a function call to:

  • Supply one argument for each parameter, using values of appropriate types. section 3.1.2
  • Capture a returned result in a variable when it will be needed later. section 3.1.2
  • Test behavior by calling the function with different inputs, including interactive calls. section 3.3.1
  • Follow nested execution: one function can call another, then continue after that inner call returns. section 3.5

Calling a function and checking its result

Given a function named money_made, call money_made(10, 15, 17). Python passes the three arguments, computes the result, and displays 20. Calling it with 10, 17, and 15 displays -20; equal prices display 0. section 3.3.1

# call the larger function with the values 3 and 5
# store the result in a variable called result
# then print result
result = larger(3, 5)      #1
print(result)

A compact Python example shows how a call passes values, stores the returned value, and prints it. section 3.1.2

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains arguments, return values, variables, nested execution, and interactive testing, but stops short of implementation internals.
Examples
Demonstrates larger, money_made, max, input, print, and a nested sequence of illustrative function calls.
What it assumes
Assumes basic familiarity with Python functions, parameters, variables, and return statements while explaining calls from first principles.
What you can do after
Apply it in Python by calling functions, capturing results, testing inputs interactively, and tracing nested execution.
How it connects
Connects function calls with parameters, arguments, return values, variables, problem decomposition, and unit testing.

Also explained in

Compare how 7 books explain call →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.