0
Data types and variables.
Please what are the similarities between a data type and a variable in a programming language? Can someone help me with that
2 Réponses
+ 3
Variable is word what store some value. Like X in math.
For example we can have, variable named age, then we assign value to this variable like 18.
age = 18;
Each language have its own way in defining variable, this one is python example, but in javascript for example we can use next:
var age = 18;
Data type is type what value have, it can be:
- number (like in example above 18)
- float (number with decimals 3.14)
- string (word or sentence, what is usually inside quotes like this "Hello world")
- boolean (true or false, or in some languages is typed with capital letters like True or False)
- arrays or lists (usually it have next syntax [1,2,3], it is comma separated list of values, some languages can have list/arrays of only one data type like just numbers, but javascript for example can mix them like this [1,"some word", true] )
- objects (mostly it have next syntax
{
"name" : "John",
"lastName": "Smith",
"age": 18
}
So object have key:value pair separated by comma)
This is most used data types
+ 1
Hey I have a box for clothes only
ClothesOnly 📦 = 👕 <item of type
^ ^
type > storage of type
Somthing like that 🙃