This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
en:variables [2016/01/01 22:42] 127.0.0.1 external edit |
en:variables [2016/08/07 21:19] admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
===== Variables ===== | ===== Variables ===== | ||
- | Variables | + | You can think of a variable as a place in the computer' |
+ | |||
+ | ==== Example ==== | ||
+ | |a = 99|Assigns the integer 99 to the variable a| | ||
+ | |nom = " | ||
+ | |print "Say hello to " + nom|Appends the string in nom the the string "Say hello to " and displays the result| | ||
+ | |a = a + 1|Takes the value of a and adds one to it, then store the new value back into a| | ||
\\ | \\ | ||
- | Variables that hold string values follow the same rules as numeric variables, but must end with a dollar sign ($). | + | In previous versions (before 1.99.99.8) |
- | \\ | + | |
- | When you assign a numeric value to a string variable or add a numeric value to a string (concatenate) the number will be automatically converted to a string before the operation is completed. | + | |
\\ | \\ | ||
^Variable Assignment^^^^ | ^Variable Assignment^^^^ | ||
^Operator^Name^Example^Comments^ | ^Operator^Name^Example^Comments^ | ||
- | |=|Assign a Number to a Numeric | + | |=|Assign a Number to a Variable|a = 9| | |
- | |=|Assign a String to a String | + | |=|Assign a String to a Variable|z = " |
- | |=|Assign a Number to a String | + | |=|Assign a Number to a Variable|q$ = 9.9| | |
- | |+=|Add to Numeric | + | |+=|Add to a Variable|a += 7|Same as a = a + 7| |
- | |+=|Concatenate to String | + | |+=|Concatenate to a Variable|f += " |
- | |-=|Subtract from Numeric | + | |-=|Subtract from a Variable|a -= 9|Same as a = a - 9| |
- | |*=|Multiply | + | |*=|Multiply |
- | |/ | + | |/ |
- | \\ | ||
- | < |