INTRODUCTION TO MODERN PYTHON: BASICS
Tags: beginners, programming, python, codenewbie
Published: 2022-02-11 20:32:47

By the end of this article you would learn the following;


- What is python, its origin and its application.

- The advantages of  python as compared to other languages.

- Explain with examples the use of  data types and 
  variables.

- Explain the use of functions and methods in python.

- Explain basic control flow if/else statements.



 
<u>WHAT IS PYTHON</u>
<p> Nowadays PYTHON is one of the most popular programming languages(PL). </p>
<u>**Definition**</u>
Python is an interpreted high level, general purpose programming language. Its design philosophy emphasis code readabilaty with use of indentation.  
<u>**ORIGIN**</u>
 <p> The PL PYTHON was designed in the late 1980`s by GUIDO VAN ROSSUM.  It was first released in 1991 as PYTHON 0.9.0. for the past years different versions of python have been released and the newest version was released in 2020 which is python 3.9. </P>
**FIELDS OF APLICCATION OF PYTHON**
Since PYTHON is a general purpose PL it can be used in many fields like;

- AI and Machine learning

- Data analytics

- Data visualisation

- Web development 

- Game development 

- Finance.
**Advantages of python as compared to other languages.**
   

- Python is a user friendly PL.
  

- Taking a PL like C we notice that python takes less lines so as 
  to perform a certain task.
   IN PYTHON.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/68en70sxcclp4zj7lb0t.png)
    IN C.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fiev9fbvr62xuxkyngkk.png)

- Also comparing python with javascript, python can be used both 
  as a scripting language and also as a programming language 
  whereas javascript is  only a scripting language.


<u>**Getting started with python programming.**
</u>
<u>INSTALLING PYTHON</u>

You can get the link [here](https://www.python.org/downloads/)

Once installed you can get the version of python installed by opening the cmd(comand prompt) in windows or the terminal in UNIX and then type python --version 


Also there are different IDE`s one can use such as VScode, Anaconda, Spyder, Pycharm just to name a few.

Now that we are done with the installation let us dive into coding.
In order to begin with any programming language we need to first look at the basics.


**<u>Variables</u> and <u>Data types</u>** 

**Variables**
 A Variable is a storage location paired with an associated symbolic name, which contains some known or unknown quantity of information refered to as value.

it can be a word or a sentence or even a letter but not a number depending on the programer that is used to store a known or an unknown value..

```
`gender=" female"
 name='DIVINE'`
```
from the above gender and name are variables.
**<u>Rules for naming variables.</u>**

1. you should not start a variable with numbers.
EXAMPLE
 19gender is a wrong variable.

2. special characters like $,!, /, \, # should not be added to your variable.

3. your variable name should not be seperated. We only seperate variables using an underscore(_).
EXAMPLE
`choir_singer`

4. In python variables are case sensitive.. 
**Data types**
   They include;
Numerical data type
Strings
List
Tuples
Sets
Dictionary
Range.

You can learn more about each of these data types [here](https://www.google.com/amp/s/www.edureka.co/blog/variables-and-data-types-in-python/amp/)

**<u>functions and methods</u>**
**FUNCTIONS**
 A function is a block of code that runs when it is called.
a function is defined with the **def** keyword.
**Layout.**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3m9zc4gf54a7li8vz72l.png)
Learn more about functions [here](https://www.w3schools.com/python/python_functions.asp)
**Methods**
n Object-Oriented Programming, we have objects. These objects have both properties and behavior. Morover, properties of the object are defined by the attributes and the behavior is defined using methods. 
we have 3 types of methods which are

- Instance Method

- Class Method

- Static Method
Learn more about methods[here](https://www.analyticsvidhya.com/blog/2020/11/basic-concepts-object-oriented-programming-types-methods-python/)

**<u>Basic control flow and if/else statements</u>**
 In python, control flow or flow control statements refers to the order in which a code is being executed.
They inchude:**while**, **for**, **if**.
Also control is regulated by conditional statements, loops and function calls.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8i73r3ru5s5e63zxik1.png)
**Simple if/else statement.**
Decision making is required when we want to execute a code only if a certain condition is satisfied.

<u>Layout</u>


```

`if condition:
    code
else:
    code `
```
**FLOWCHART**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s0ki110b01yu0vxjid45.png)learn more about control flow statements [here.](https://www.educative.io/edpresso/what-are-control-flow-statements-in-python).
_THANK YOU FOR READING_