Python Basics 101
Published: 2021-07-24 20:36:25

![Python Programming Language](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ph3ggpenq8sjzyn27q2n.png)
Python is a programming language that is meant for everybody. Irregardless of your age, sex or location you can learn python. The python programming language is simple to learn yet so powerful that it can be used to develop specialized programs.  Python has become well known as the driving force behind the development of fields of data science, machine learning, and artificial intelligence. However, this is not python’s limits. Python can be applied in many fields of technology development.

Now that you have some knowledge of what python can do, you have to know how to use it well before you think about specialization. 

##0.Setting up
Before we can use python, we have to install necessary material. We need Python3 and a text editor such as Visual Studio Code, Sublime text, notepad++, or atom.
For python3, go to https://www.python.org/downloads/ to download the latest version of python3.
For a text editor you can choose one that you are comfortable with. For me, I use [notepad++](https://notepad-plus-plus.org/downloads/) though VS code,sublime text and atom offer excellent alternatives.
After the installs are done, you are now ready to learn the python basics.

##1.Keywords
Keywords or reserved words in python are words that are already in python and have a specific use or meaning. This words cannot be used as variable names (we’ll get to variables in a moment).
![Python keywords](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sf4tzx38yyp5rnvb34bj.png)
 
##2.Variables
A variable refers to a named memory location where a programmer can store data and later retrieve it in python using the variable name. The value stored in the variable can be changed in future.
```python
Sample_variable = ‘oranges’
```
In the example above we ask python to store ‘oranges’ in a memory location and name the location sample_variable

There are rules in naming variables in python.The variable:
1.Must start with a letter or underscore
2.Can only consist of letters,numbers, and underscore
```python
colour  coLour  coloUr  ColouR coLoUr
cOlour  colOUR  colOUr  cOLour cOLouR
```
Watch out for capitalization of letters in python. In the example above all words may be made up of same letters but different capitalization make them different variables.
Make sure to give names to variables in a way that you can remember.

##3.Data Types in Python
Numbers
String
List
Dictionary
Set
Tuple

The basic data types that we will introduce now are numbers and strings.
###Numbers 
Numbers or numerical data type is used for numerical values. We have 2 main types of numerical data types.
integers are whole numbers.
```python
#1 and 700 are integers
x = 1
y = 700
```
float data types are decimal point values
```python
#0.25 and 15.396 are float
x = 0.25
y = 15.396
```

###String 
A String data type refers to characters or alphabets enclosed in single or double quotation marks.
```python
name = 'learner'
course = "python"
```
```python
print('hello world')
```
##4.Operators
Operators or expressions in python are for operations between two values or variables. Because of a lack of mathematical symbols on computer keyboards, we use certain keyboard keys to express classic math operators.

addition +
subtraction -
multiplication *
divisions /
Exponents **
Remainder %

**Addition**
add 1 and 2
```python
>>>x=1+2
>>>Print(x)
3
```

**Subtraction**
subtract 2 from 3
```python
>>>x=3-2
>>>Print(x)
1
```

**Multiplication**
multiply 4 and 2
```python
>>>x=4*2
>>>Print(x)
8
```

**Division**
divide 8 by 2
```python
>>>x=8/2
>>>Print(x)
4
```

**Exponentiation**
find 2 power 4
```python
>>>x=2**4
>>>Print(x)
16
```

**Remainder**
divide 3 by 2 and store the remainder in x
```python
>>>x=3%2
>>>Print(x)
1
```

###Order of Precedence
Python has an order in which it solves operations.
It can be summarized as PEMDAS:

P-Parentheses
E-Exponentiation
MD- Multiplication and Division
AS- Addition and Subtraction

So Python will solve the parentheses first, then the exponentiation, multiplication and division, and addition and subtraction respectively. Multiplication and division are on the same level, as are addition and subtraction. 
On the same level we solve from left to right.

```python
#How python solves step by step:
X=1+2**3/4*5+3*(4-5) #solve parentheses first
X=1+2**3/4*5+3*-1  #then exponent
x=1+8/4*5+3*-1  #then multiplication and division from left to right
X=1+2*5+3*-1
X=1+10+3*-1
X=1+10+-3  #addition and subtraction from left to right
x=11-3
X=8
```
Once you understand these basics, you are well on your way to becoming a great pythonista.