Foundations of Python

You are currently auditing this course.
64 / 134

Flow of Execution

  • Execution always begins at the first statement of the program. Statements are executed one at a time, in order from top to bottom.

  • Function definitions do not alter the flow of execution of the program but remember that statements inside the function are not executed until the function is called.

  • A function call is like a detour in the flow of execution. Instead of going to the next statement, the flow jumps to the body of the function, executes all the statements there, and then comes back to pick up where it left off.

  • You need to create a function before you can execute it. In other words, the function definition has to be executed before the first time it is called.

Try calling the function before executing it and observe the result,

get_name()
def get_name():
    print("Cloudxlab")
INSTRUCTIONS
  • Correct the function call in the example above and execute it correctly.

Loading comments...