Python 101: Ultimate Python Guide
Tags: beginners, python, codenewbie, 100daysofcode
Published: 2022-02-14 15:41:44

## Python 101: Ultimate Python Guide
## Introduction to Python
Python is an interpreted, interactive, object-oriented programming language. It is a popular programming language created by Guido van Rossum, and released in 1991.

It is used for:

 - Web development
 -  Desktop Application
 - Automation
 - Data science, Artificial Intelligence, Machine Learning

## Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). It has a simple syntax similar to the English language that allows developers to write programs with fewer lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-oriented way or a functional way. It uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.
It relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
Python programs have the extension .py and can be run from the command line by typing python file_name.py.

## Concepts we will be going through today:

 1. How to install Python 
 2. Your first python program 
 3. Comments 
 4. Variables
 5. Arithmetic Operators
 6. Comparison Operators
 7. Logical Operators
 8. Control Flow and Conditional operators

**1)	How to install Python**
The most recent major version of Python is Python 3, which we shall be using. In this tutorial, Python will be written in a text editor. It is possible to write Python in an Integrated Development Environment, such as VSCode, Pycharm, Atom, Netbeans or Eclipse which are particularly useful when managing larger collections of Python files.
[Here](%28https://wiki.python.org/moin/BeginnersGuide/Download%29) is a guide on how to install python on your machine.

[Here](https://www.youtube.com/watch?v=MlIzFUI1QGA) is a guide on how to install VSCode.

**2)	Your first python program**
Create a new folder in your machine where you will be saving your python files, for example PythonProjects. Launch the VS code and open the new folder you created, PythonProjects. Create a new python file, helloworld.py file and enter the code below.

![image](https://user-images.githubusercontent.com/40733583/153882057-3cb02569-7244-4a90-acde-544677aca6b8.png)

**print()** is a built-in function in Python.

**3)	Comments**
You can add comments to your Python scripts. Comments are important to make sure that you and others can understand what your code is about. To add comments to your Python script, you can use the # tag. These comments are not run as Python code, so they will not influence your result.
![image](https://user-images.githubusercontent.com/40733583/153883859-0ea57b20-02c6-4680-ab1c-2845c65be198.png)

**4)	Variables**
Variables are containers for storing data values. Python has no command for declaring a variable. Just type in the variable and when values will be given to it, then it will automatically know whether the value given would be an int, float, or char or even a String. Note that variables are case-sensitive and the first character can either be character or underscore and not a digit. Once you create such a variable, you can later call up its value by typing the variable name.
![image](https://user-images.githubusercontent.com/40733583/153865716-efdc242e-9e71-49bb-b708-6723a6bd3f49.png)

**Output**
 ![image](https://user-images.githubusercontent.com/40733583/153865867-c7ea3743-71af-41b5-a89a-f484d629476f.png)

**5)	Arithmetic Operators**
They are used to perform mathematical operations like addition, subtraction, multiplication, and division.
![image](https://user-images.githubusercontent.com/40733583/153865971-de43e63e-d14b-4080-ba87-f5909e065704.png)

**Output**
 ![image](https://user-images.githubusercontent.com/40733583/153866070-5c99c7af-3ad8-4f3f-9447-ec61fff8bb60.png)

**6)	Comparison Operators**
Compares the values. It either returns True or False according to the condition.
![image](https://user-images.githubusercontent.com/40733583/153866171-954f9f80-849c-491c-8878-ba469f4c4f29.png)
 
**Output**
 ![image](https://user-images.githubusercontent.com/40733583/153866276-2e0110b5-336f-4e9b-a43f-d552013cc8b0.png)

**7)	Logical Operators**
They perform Logical AND, Logical OR, and Logical NOT operations. It is used to combine conditional statements.
![image](https://user-images.githubusercontent.com/40733583/153866370-63a497cf-1ee0-4fc0-94af-fae2042faad6.png)
 
**Output**
![image](https://user-images.githubusercontent.com/40733583/153866443-209f3378-72f8-4784-b61b-8b8c9b316d39.png)
 
**8)	Control Flow and Conditional operators**
So far the code has consisted of sequential execution, in which statements are always performed one after the next, in exactly the order specified. Frequently, a program needs to skip over some statements, execute a series of statements repetitively, or choose between alternate sets of statements to execute. That is where control structures come in. A control structure directs the order of execution of the statements in a program (referred to as the program’s control flow).

 - **if Statement**

if statement accepts boolean values – if the value is true then it will execute the block of statements below it otherwise it will not. As we know, python uses indentation to identify a block. 
Let us use a real-life scenario “If the weather is sunny, I will not wear a jacket”
![image](https://user-images.githubusercontent.com/40733583/153866637-0f6af303-d50a-4f68-b085-c7713ad40dc9.png)
 
**Output**
![image](https://user-images.githubusercontent.com/40733583/153869161-59ef08e6-cf6b-4b5f-b7be-31d6e2875b9e.png)

 - **if-else Statement**

Example: “If the weather is not sunny, wear a jacket”
![image](https://user-images.githubusercontent.com/40733583/153871570-6398a5c6-acf1-48f9-93f3-3dea5953fe8c.png)

**Output**
![image](https://user-images.githubusercontent.com/40733583/153871605-962e5271-586e-4ae8-ad58-d5a658001637.png)

 - **elif statement**

Example: “If the weather is sunny, no jacket, else if(elif) the weather is cold, wear a jacket, else wear a light jacket”.
![image](https://user-images.githubusercontent.com/40733583/153873041-62aff520-0d3b-44fd-b1c2-0bf8bc2c82c8.png)
Output
![image](https://user-images.githubusercontent.com/40733583/153873369-55727378-413d-4c63-82c9-0e69afe9749c.png)