Variables are one of the core mechanics of Programming
In python, there are 7 types of default variables:
- Integers (num)
- Floats (num)
- Booleans (unq)
- Strings (chars)
- Sets (group)
- Tuples (group)
- Lists (group)
1. Integers
Integers store numerical values without decimals. For example: 51, 0 or -1. However, if they are divided and the result is a Non-terminating decimal number Explanation ‣(a number with an infinite decimals), the result will be a float rounded to a certain decimal point. (eg. 1/3 might be 0.33334)
2. Floats
Floats are similar to integers, but they have decimals. An example: 1.0123 or -10.231213. Depending on the software, floats are always rounded to a certain decimal point.
3. Booleans
A Boolean is either true or false, no other exceptions. (eg. variable = True Explanation ‣(the capitalization of the first letter is important so the program doesn’t think it’s a variable ))They can be used to perform actions without having to use a string.
4. Strings
A string is a list of characters. (eg. variable = ‘Hello World!’ Explanation ‣(the ‘ ‘ are needed, but can be replaced with “”))Additionally, some characters are special and affect the string. To stop the string from bugging out, a backslash (\) can be put behind the character. Examples of characters bugging out the string: ‘ (if the string is made using ”), and ” (if the string is made using “”).Keep in mind that adding a backslash to certain characters will change the string. For example: \n will make the rest of the string be on a newline.
5. Sets
A set is a container for all types of variables. However, a set is a non-changable variable. Which means that the elements inside a set can not be changed but the whole set can be set to another set. Also, there cannot be repeat elements in a set. Converting a variable into a set organizes the set. Duplicate elements are allowed
6. Tuples
7. Lists
