A variable is a named container that can store a value of a certain data type, such as a number, a string, or a Boolean. A variable can be reused throughout a program by referring to its name, and its value can be changed or reassigned as needed. For example, in the following Python code, x is a variable that is assigned the value 10, then reassigned the value 20:
A method is a set of instructions that performs a specific task, usually associated with an object or a class. A method can take parameters as inputs and return a value as output, but it cannot be reassigned to another value. For example, in the following Python code, print is a built-in method that takes a parameter and prints it to the console, but it cannot be assigned to another value:
A constant is a named container that can store a value of a certain data type, but unlike a variable, its value cannot be changed or reassigned once it is defined. Constants are usually used to store values that are fixed or constant, such as mathematical constants, physical constants, or configuration settings. For example, in the following Python code, PI is a constant that is assigned the value 3.14, and it cannot be reassigned to another value:
A function is a named block of code that performs a specific task, usually independent of an object or a class. A function can take parameters as inputs and return a value as output, but it cannot be reassigned to another value. For example, in the following Python code, add is a user-defined function that takes two parameters and returns their sum, but it cannot be assigned to another value:
Therefore, the correct answer is B. Variable, as it defines a reusable value that can be reassigned.
References:
CompTIA IT Fundamentals+ (ITF+) Certification Exam Objectives, page 16, section 4.1
CompTIA IT Fundamentals+ (ITF+) Study Guide, page 207, section 8.1
CompTIA IT Fundamentals+ (ITF+) All-in-One Exam Guide, Second Edition, page 301, chapter 9