Python 101 : The Ultimate Python Tutorial For Beginners
Tags: python, opensource, machinelearning, ai
Published: 2022-04-24 20:23:42

**What is python programming?🤔**

**Python** is a high level programming language. It emphasizes code reusability with the use of significant indentation. It was designed by Guido Van Rossum on 20th February 1991.

**Applications of python programming**

Python programming is widely used. These are some of the ways it is majorly used in:
1. Web development
2. Game development
3. Machine learning and Artificial Intelligence
4. Data Science and Data visualization
5. Desktop Applications
6. Automation

**Advantages of using python programming language**

1. It is easy to use
2. It's improved productivity
3. It's an interpreted language
4. It's dynamically typed
5. It's free and open-source

**Python installation**

Visit https://www.python.org/downloads/[](url)
Select your Operating system
Select the release or version, and click on it to download.
Double click on the file to execute and install. For window mark "add to system paths" An alternative way to install python on Linux is to run

`> sudo apt install python3 or sudo apt install python on the terminal`

**Variables in python**
A variable is a reserved memory location to store variables. There are four types of variables;
  1. Integers
  2. Long Integer
  3. Float
  4. String

There are rules which are followed when declaring variables which are;

1. Keywords cannot be used to name variables.

```
Example: def = 5
# This is incorrect because def is a keyword in python
```
2. Must start with a letter or underscore character.

```
Example: a)variable = name
         b)@variable = name
 #when executing this type of code a will be executed but b wont be executed because it doesn't start with letter or underscore.
```
3. Variables are case sensitive, (age, Age, and AGE) are different variables

```
Example: #When you declare a variable it must be consistent in you code.
i) age = 15
ii) Age = 14
#the output of age will not be the same with that of Age
```
4. Can only contain alpha-numeric character and underscore(A- Z,0-9, _)

```
Example:
     sum = $400
     sum = 400
  #sum is executable while $um is not because dollar sign is non-alphernumeric

```
5. Variable cannot start with a number.

```
Example 
num1 = 7
2num = 8
# 2num is not executable because variables cannot start with numbers.
```
**Literals in python**

Literals refers to data stored in variables. Different types of literals include:

      1. Boolean literals
      2. Special literals
      3. String literals
      4. Numeric literals
      5. Literal collections

**1. Boolean literals**
They are only two: True, False.

```
Example:
games= [soccer,tennis,rugby]
print(soccer in games)
True
print(badminton in games)
False

```
**2.Special characters**

Python contains one special literal. "None", it is used to define a null variable. If "None" is compared with anything else than "None" it will return false.

**3. String literals**
These are characters that are surrounded by single or double quotes.
```
#In single quote
name = 'Daniel Brian'

#In double quotes
name = "Daniel Brian"
```
**4.Numerical literals**
They are of different types;
Complex
Integers
Float


1. Complex
These are numbers having both a real and imaginary part in the form of x + 5j, where x is real and y is imaginary.
2. Float
These are both positive and negative numbers with
floating.
point numbers(with decimals).

```
 num =0.256784
```
3. Integers
These are both positive and negative integers without floating point numbers.

```
a = 28
```
**4. Literal collections**
These are;
 a)_List_:Its an ordered sequence of data.They are mutable meaning if you want to change anything in a list you can change.

```
Example:
 A=["Earth","Mars","Jupiter"]
```
b)_Tuples_: is a sequence of immutable sequence objects.

```
Example:
mytuple = ("apple", "banana", "cherry")
```
c)_Dictionaries_: They are special characters which allows one to store information in key-value pairs

```
Example:
monthconversions={
"Jan":"January"}
```
d)_Set_:They are used to store multiple items in a single variable.
 

```
 Example:
>>> A = {1, 2, 3, 4, 5} >>> B = {4, 5, 6, 7, 8}

```