--Originally published at M E R I N O
Variables:
First, we have to know what is a variable?
In programming, a variable is a value that can change, depending on conditions or on information passed to the program
-WhatIs.com
Now, we know what is a variable but… How do I assign it?
To assign a variable you just need to add the equal sign (=) that’s it, you now have a variable… Kinda.
Also you can do multiples assignments like this:
Or assign the same value to different variables like this:
Types of variables:
There are 6 main datatypes of variables.
1- Numbers:
In this category are 4 “subcategories”:
- Integers (int)
- Long Integers (long)
- Floating point real values (float)
- Complex Numbers (complex)
Here are some examples:
2 -String:
In a string variable you can add any type of characters, number, symbols letters, you only need to add “” and write whatever you want, like this.
3- List:
In this variable you can add various values to a single variable, you declare it with [] and separate the values with a ” , ” like this
Then you can choose the value you want or the range of values. For a single value you only write between the [] the number in which the value is positioned, be careful because in Python, the first value is the value 0
To remove an element from the list, you can use del list [#] or you can use list.remove (“value”). It only takes out the value but the sequence keeps going with the next value . Here is an example:
Also you can change or update the values of a list, like this:
4 – Tuple:
A Tuple is like a list, but less flexible and instead of using [] we use (). You can’t replace values. Example:
5-
Continue reading "You’re not my Type sorry" →