From 5d0b7731384c2a2b2bf410bc90e542300f0a0ad3 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 13 Feb 2025 19:25:10 -0700 Subject: renamed files to contain numbering --- tutorials/basics_of_python.md | 155 ------------------------------------------ 1 file changed, 155 deletions(-) delete mode 100644 tutorials/basics_of_python.md (limited to 'tutorials/basics_of_python.md') diff --git a/tutorials/basics_of_python.md b/tutorials/basics_of_python.md deleted file mode 100644 index 5c12ff4..0000000 --- a/tutorials/basics_of_python.md +++ /dev/null @@ -1,155 +0,0 @@ -# Basics of Python - -This page contains important fundamental concepts used in Python such as syntax, operators, order or precedence and more. - -## Syntax -### Indentations -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. -### 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. -If you have an entire block of text or code that needs to be commented out, the triple quotation marks (""") can be used. Once used all the code after it will be considered a comment until the comment is ended with the triple quotation marks. -## 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 | - - -## 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 | - -## Variables - -A **variable** in Python is a name that stores a value, allowing you to use and manipulate data efficiently. - -#### 1. Declaring and Assigning Variables - -In Python, you don’t need to declare the type of a variable. Just assign a value using `=`. - -```python -x = 10 # Integer -y = 3.14 # Float -name = "Joe" # String -is_valid = True # Boolean -``` - -#### Rules - -- Must start with a letter or `_` -- Cannot start with a number -- Can only contain letters, numbers, and `_` -- Case-sensitive (`Name` and `name` are different) - -#### **4. Updating Variables** - -You can change a variable’s value at any time. - -```python -x = 5 -x = x + 10 # Now x is 15 -``` - -Or shorthand: - -```python -x += 10 # Same as x = x + 10 -``` - -#### **5. Multiple Assignments** - -You can assign multiple variables at once: - -```python -a, b, c = 1, 2, 3 -``` - -Similarly we can assign the same value to multiple variables: - -```python -x = y = z = 100 -``` - -#### **6. Variable Types & Type Checking** - -Use `type()` to check a variable’s type. - -```python -x = 10 -print(type(x)) # Output: - -y = "Hello" -print(type(y)) # Output: -``` - - -#### 8. Deleting Variables - -Use `del` to remove a variable: - -```python -x = 10 -del x -``` -- cgit v1.2.3