digital literacy for everyone
[lit]हिंदी मैं[lit] [lit]https://codeinfig.neocities.org/figconcepts/variables-hi.html[lit]
/variables/ | [[input]] | [[output]] | [[basic-math]] | [[loops]] | [[conditionals]] | [[functions]]
variables are a combination of name and value. variable assignment is when a variable is created or updated with a value, such as:
height = 5
in fig, the = is optional and most lines of code begin with a variable. the exceptions to this are for a few special commands, such as the "textmode" command-- which do not share the line with other commands.
unlike constants, variables can have their values changed or updated:
there is little point in setting height to 5 just to set it to 6 on the next line, but sometimes a program will change the value of a variable somewhere else in the code, if you tell it to.
when you read part of a file, or get input from the keyboard, it is useful to have that input stored in a variable.
unless you write their contents to a file, variables do not get saved when you quit the program. in the above example, the variable "height" has the value of 6 but when the program stops, height will not have any value at all.
variables have type-- this refers to the kind of data (the value) they are storing. 5 is a numeric value, an integer (whole number without fraction or decimal.) 5.5 would be a "float" (number with a decimal point.) fig treats both types as "numeric" collectively.
a value in quotes "like this" is called a string-- a string of characters. this is a value that can hold letters, numbers, punctuation and spaces-- along with a few other characters like "tab."
another variable type is the array-- while most variables associate a single name with a single piece of data, an array associates a single name with zero, one or multiple pieces of data.
setting variables is one of the 7 most important concepts in fig, but by themselves, variables are not very useful without input, output, basic-math, loops and conditionals.
back to fig concepts: [url]https://codeinfig.neocities.org/figconcepts/index.html[url]
fig main page: [url]https://codeinfig.neocities.org/fig/index.html[url]