Concepts of programming - Naming Procedures and Functions

Pybeginner
By -
0

 


We’ve already seen how we can use names to represent numbers (both integers like 3 and -325 and decimal numbers like 2.4 and -322.9392), strings (like "Hi There"), and images. When we do calculations using the names, the computer will look up the value for each name, and then use the value in the calculation. We can also name a sequence of statements and then ask the computer to run that sequence whenever we use that name.

This is similar to asking someone to do a dance that they know, like the Macarena or Salsa. Once you know the dance you can do the steps.

In programming there are two different terms used for a named sequence of statements: procedure and function.

 

procedure accomplishes some task or makes something happen, but doesn’t return anything.

A function returns a result. Many procedures and functions are built into Programming languages.

 

Concepts from computing


Abstraction - Abstraction means focusing on just the important details in a context. An example is the abstract female figure used to indicate a restroom for females.

Actual Parameter - An actual parameter is a value passed into a procedure or function when it is called. In forward(50) the actual parameter is 50. This is also called an argument.

Argument - An argument is a value passed into a procedure or function when it is called. In forward(50) the argument is 50. This is also called an actual parameter.

Call - You can call or run a procedure or function by using the name of the procedure or function followed by values to pass into the procedure or function. An example is forward(50). This is also known as executing or running a procedure or function.

Execute - Execute means to run or call a procedure or function.

Formal Parameter - A formal parameter is named input in the definition of a procedure or function. This is also called a parameter.

Function - A function is a named set of instructions that returns a result. An example is the abs(num) which returns the absolute value of the num.

Library - A library is a named group of related procedures and functions. An example is the Turtle library.

Parameter - A parameter is input to a procedure or function that is named when you define the procedure or function. It will be assigned a value when you call the procedure or function. This is also called a formal parameter.

Procedure - A procedure is a named set of instructions that does not return a result, but can cause something to happen like the turtle forward(amount) procedure.

Run - To run a procedure or function use the name of the procedure or function in your program. This is also known as calling or executing a procedure or function.

Post a Comment

0Comments

Post a Comment (0)