Variables

Variable Naming Rules

As I said in Basic Terms, you can use almost everything as your variable name, but you neet to follow those rules:

examp1e

For example, those variable names are acceptable:

example Example _example _example2

And those are not acceptable:

2example example!

Because variable names are case sensitive, so example and Example are two different names.

Assigning a Variable

Assign a variable means you are giving a value to a variable.

Here are some examples: (sentence after # is comment)

Also, you can assign a variable by another variable:

Tip: Don’t understand a = 10 as “variable a equals to 10”, but “give value 10 to variable a”. You will know why in the “Operators” handout.

Test If it Works

Now we already assigned a value to a variable, but how can we actually confirm it? Use print() function. Since we are not starting teaching function yet, the only thing you need to know is put your variable name in the brackets, this function will show what’s in the variable in the shell.

For example:

After running this, 12345 should shown in the shell.

https://img.shields.io/badge/By-Pegasis-green.svg