diff options
Diffstat (limited to 'tutorials/basics_of_python.md')
| -rw-r--r-- | tutorials/basics_of_python.md | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tutorials/basics_of_python.md b/tutorials/basics_of_python.md new file mode 100644 index 0000000..abced24 --- /dev/null +++ b/tutorials/basics_of_python.md @@ -0,0 +1,83 @@ +# Basics of Python + +^88ce39 + +This page contains important fundamental concepts used in Python such as syntax, operators, order or precedence and more. + +## Syntax +In python *indentations* or the space at the start of each line, signifies a block of code. This becomes important when we start working with function and loops. + +## Operators +### Arithmetic operators +| Operator | Name | +| --- | --- | +| + | Addition | +| - | Subtraction | +| * | Multiplication | +| / | Division | +| % | Modulus | +| ** | Exponentiation | +| // | Floor division | + + +### Comparison operators +| Operator | Name | +| --- | --- | +| == | Equal | +| != | Not equal | +| > | Greater than | +| < | Less than | +| >= | Greater than or equal to | +| <= | Less than or equal to | + +### Logical operators +| Operator | Descrription | +| --- | --- | +| and | Returns True if both statemetns are true | +| or | Returns True if one of the statements is true | +| not | Reerse the result, returns False if the result is true | + +### Identity operators +| Operator | Description | +| --- | --- | +| is | Returns True if both variables are the same object | +| is not | Returns True if both variables are not the same object | + +## Order of Operation +| Operator | Description | +| --- | --- | +| () | Parentheses | +| ** | Exponentiation | +| * / // % | Multiplication, Division, floor division, and modulus | +| & | AND | +| ^ | XOR | +| \| | OR | +| == | Comparision, identity and membership operators | +| not | logical NOT | +| and | AND | +| or | OR | + +## Comments +Comments can be added to your code using the hash operator (#). Any text behind the comment operator till the end of the line will be rendered as a comment. + +## Data types +Data types are different ways a computer stores data. Other data types use fewer bits than others allowing you to better utilize your computer memory. This is important for engineers because +The most common data types that an engineer encounters in python are numeric types. +- 'int' - integer +- 'float' - a decimal number +- 'complex' - imaginary number + + +The comprehensive table below show all built-in data types available in python. + + + +| Category | Data Type | +| ---------- | ------------------------- | +| Text | int, float, complex | +| Sequance | list, tuple, range | +| Mapping | dict | +| Set | set, frozenset | +| Boolean | bytes, bytearray, memoryview | +| Binary | bytes, bytearray, memoryview | +| None | NoneType | |
