PYTHON FOR NEWBIES
Published: 2022-02-14 19:59:05


### GETTING STARTED
Python programming language is a high level, general purpose language. This means that it is written in human readable language and designed to solve a particular problem. 
Python is suitable for including but not limited to:
- Web Development
- Data Science
- Machine Learning
- Game Development
- Data Engineering
- Robotics
- Automation

### INSTALLING PYTHON
To install python visit: [Python](https://www.python.org/downloads/), scroll down to active releases to see which version is secure for download. 
**NOTE:**
Python 2.7 is no longer in use.
Once you've settled on a specific version, select download to download
Take note of the operating system your machine uses before download.


##### Python on visual-studio and pycharm:
To get started with python on visual-studio, follow [Getting Started with Python in VS Code](https://code.visualstudio.com/docs/python/python-tutorial) and pycharm [Get Started](https://www.jetbrains.com/help/pycharm/quick-start-guide.html)

### WRITING YOUR FIRST PROGRAM
Python uses `print` function to output text to the console/command line. Print must be followed by a parenthesis which encloses the output we want to generate. Open your command line interface (CMD in Windows, terminal in Mac and Linux) and type the code snippet below then press enter

```python
print("My name is Jane Doe")
```

Feel free to modify the code with various other inputs 

A variable is used to store a value. It can e on of the various inbuilt python types or custom types, but for now we shall use the inbuilt python types i.e 

- Numbers e.g.

```python
num1 = 1 # type int
num2 = 8.6 # type float
```

- List - this holds several items of the same or different types e.g.

```python
numbers=[1,2,3,]
letters = ['a', 'b', 'test']
empty_list = []
```
 
- String - this is a combination of letters or numbers in any order, commonly known as word or sentence. You can use both single and double quotes to denote a string, just make sure to match the start and the end e.g. Sample code :
 
```python
string_1 = 'My name is Jane Doe' # sample using single quotes
string_2 = "1" # sample using double quotes
string_3 = "a3923"
string_4 = " "
```

- Tuple - this is similar to a list, just that its contents cannot be changed. Declare one using the syntax below

```python
my_tuple = (1,2,3,4,)
```

- Dictionary - This is used to hold key value pairs, e.g. students and their marks 

```python
students = {
       "john" : 35,
       "jane": 24,
       "alice": 99,
       "peter": 1
}
```

You can assign a variable to hold your name and change it during runtime for example

```python
name= "Jane Doe"
print(name)
```

 **Arithmetic operators**
 
| Operator | Description | Syntax |
| ----------- | ----------- | ----------- |
| + | Addition| a+b  |
| - | Subtraction | a-b|
| *| Multiplication | a*b |
| /| Division| a/b|
| %| Modulus | a%b|
|//| Quotient | a//b|
|**| Exponent | a**b|

```python
a=10
b=6
c=2

print(a+b)
print(a-b)
print(a*b)
print(a/c)
print(a%b)
print(a%c)
print(a//b)
print(a//c)
print(a**b)
print(a**c) 
```


**Logic Operators**

| Operator | Description | Syntax |
| ----------- | ----------- |  ----------- |
| and | True if both operands result is true| a and b  |
| or | True if either operands result is true| a or b|
| not| True if both operands result is false  | a not b |


## REFERENCES
[Python Download Page](python.org/downloads/)
[Pycharm Download Page](jetbrains.com)
[VS Code Python Docs](visualstudio.com/docs/python/python-tutorial)