3.12 Calling Procedures - Syntax Terrors

What is a Procedure?

Key Points

  • A procedure is a reusable group of instructions

  • Also called functions or methods

  • Lets you avoid rewriting the same code

JavaScript


// A procedure (function) to display a message
function showMessage() {
    console.log("Welcome to the program!");
}


          

In JavaScript, a procedure is called a function.

  • Use the function keyword to define a procedure.
  • Write your instructions inside curly braces {}.

This function displays a welcome message.

Python


# A procedure (function) to display a message
def show_message():
    print("Welcome to the program!")


          

In Python, a procedure is called a function.

  • Use the def keyword to define a procedure.
  • Write your instructions inside an indented block.

This function displays a welcome message.