106k views
5 votes
What is a section of reusable code that performs an action?

1) Function
2) Variable
3) Class
4) Object

User Tempire
by
8.0k points

1 Answer

1 vote

Final answer:

A section of reusable code that performs an action is known as a function. Functions encapsulate tasks or routines in programming, making code more efficient and manageable.

Step-by-step explanation:

A section of reusable code that performs an action is called a function. A function is a fundamental building block in programming that allows you to encapsulate a task or routine. When you define a function, you are creating a set of instructions that can be executed whenever the function is called, without having to rewrite the entire code sequence. This makes the code more organized, readable, and allows for easier debugging and maintenance.

On the other hand, a variable is a storage location and an associated symbolic name that contains some known or unknown quantity or information, a class is a blueprint for creating objects (a particular data structure), and an object is an instance of a class.

Therefore, the correct answer is that a function is a section of reusable code that performs an action.

User Ovolko
by
7.7k points