Learning Python
What is Python?
Python is an object-oriented high-level programming language. It is commonly used for developing websites and software, task automation, data analysis, and data visualization. Its built-in data structures, combined with dynamic typing and dynamic binding, make it very attractive for rapid application development and scripting for tying existing components together.
We basically use python for scripting and Automate our tasks.
Why is python used for scripting?
When we are writing bash script, slowly we are going to some complexity. Also, we do not have more features apart from Automating Linux tasks. Python is the easiest programing language, which gives us lots of features and libraries, using that can automation of Linux and Cloud environments.
Python Installation
Python is already installed in many Linux distributions. It may be python 2 or python 3 depending on the python version
If your version is above Ubuntu 17.10 then most probably you have python 3.6 by default
If your version is Ubuntu 16.10 and 17.04 then most probably you have python 2
you should able to install python3.6 or above follow the below steps to install
- sudo add-apt-repository ppa:deadsnakes/ppa :- to add the ppa repository
- apt search python3 :- to check all python3 versions on repository
- sudo apt-get update
- sudo apt-get install python3.6
If you are using Ubuntu 14.04 or 16.04, Python 3.6 is not in the Universe repository, and you need to get it from a Personal Package Archive (PPA).
For installation in the windows. Use the link to download https://www.python.org/downloads/
After installing python for verification use the below command
python --version :-For python2
python3 --version :-For python3 Python is an interpreted programming language, so developers can write Python (.py) files and execute them.
Get Pradyumna Kumar Das’s stories in your inbox
Join Medium for free to get updates from this writer.
Python can also be run in the command line. For that type python in the command line and it opens the interpreter then you can execute your python program. For exit, the interpreter use command exit ().
If you are using pyton3, then use python3 to open the interpreter.
Comments :
We use comments basically to explain the code, identify the sections, etc. I other team members or testers are working on this code they can identify that this code is written for this reason.
Comments are two types in python
*Single Line comment and multi-line comment.
Single Line comment is it starts with #, if you are using it , python will ignore that line.
Syntax:-
#This is a comment
print("Hello, World!")Python does not really have a syntax for multiline comments. Since Python ignores string literals that are not assigned to a variable. So we are using multiline strings (triple quotes) as comments.
Syntax :-
""" This is
Multi Line
Comment """
print("Hello, World!")Variables :-
In programming, a variable is a storage area , where we stores data.
Example :-
number = 10changing the value of a variable in Python
Output
Here the value of my_name changed pradyumna to Harish








