What is a variable in programming?

Asked by amorebise · 1 month ago

2 Answers

1
amorebise · 1 month ago Top Answer
Imagine you are at the market in Yaba or Onitsha, and you buy some items. You put your tomatoes in one bag, your pepper in another bag, and your fish in a third bag. Each bag holds something specific, and you can label each bag so you remember what is inside. In programming, a variable is exactly like one of those bags. It is a container that holds information. You give the container a name (a label), and you put data inside it. Here is a simple example: age = 16 name = "Chioma" height = 1.65 In these three lines: age is a variable that holds the number 16 name is a variable that holds the text "Chioma" height is a variable that holds the number 1.65 (representing meters) The equals sign ( = ) does not mean "equals" in the mathematical sense. In Python, it means "assign" or "store." You are saying: "Create a container called age and store the value 16 in it."

Log in to add a comment.

-1
webmin · 1 month ago

A variable in programming is a named storage location in the computer's memory that can hold a value. Variables have a name (identifier), a data type (like integer, string, boolean), and a value that can change during program execution. For example, in Python: age = 25 creates a variable named "age" with the value 25. Variables are fundamental to programming as they allow programs to store, manipulate, and retrieve data.

Log in to add a comment.