Python tutorial

Getting Started With Python is the first article in the A to Z series of python articles. A to Z series will take you from basic to advance concepts in the python programming language.

Getting Started With Python is your first step towards a journey to one of the most important language Python. It will help to install Anaconda and run your first python program.

Why Python?

1> Easy to Learn and Use:-Simple Syntax with faster Execution.

2> Hundreds of Python Libraries and Frameworks:-Before I explain this,I want you to understand what is Library and Framework.Library is bunch of code already written for you.

For Example:-

# Importing the statistics module/Library 
import statistics 
# list of positive integer numbers 
data1 = [1, 3, 4, 5, 7, 9, 2] 
x = statistics.mean(data1) 
# Printing the mean 
print("Mean is :", x) 

In above python code statistics library is used,where code of calculating mean is already written.So,In order to calculate mean in your code you don’t have to manually write code.You just need to pass your data to mean() function of statistics library.This will save your time and effort.

Framework, Think of framework as a collection of packages or modules which allow developers to write application. For example Django is a web framework for development of web application in Python.

There are many frameworks and libraries are available for python language, such as:

  • matplotib for plotting charts and graphs
  • SciPy for engineering applications, science, and mathematics
  • BeautifulSoup for HTML parsing and XML
  • NumPy for scientific computing
  • Django for server-side web development

3>Big data, Machine Learning and Cloud Computing:-Python is extensively used for Big Data, Machine Learning, Cloud Computing etc. Python libraries are being used in thousands of machine learning projects like TensorFlow, OpenCV for computer vision, etc.

Last but not the least it is one of the most sought after Programming language in IT world.

Step wise guide to installing Python

Anaconda is the best platform to learn python. In order to install Anaconda follow following steps:-

  1. Search for Anaconda in search engine.
Python Anaconda Installation

2. Click on Installation.

Python Anaconda Installation

3. Click on Installing on Windows/macOS etc based on your Operating System.

Python Anaconda Installation
fusebulbs Anaconda installation windows

4. Click on Download.

fusebulbs Anaconda installation download

5. Click on Link as per your system configuration. In my case I will select 64-bit installer.

6. Double Click on Installation .exe file.

Python Anaconda Installation

7. Follow Instructions.

fusebulbs anaconda setup installation
fusebulbs anaconda setup installation
fusebulbs anaconda setup installation
fusebulbs anaconda setup installation
fusebulbs anaconda setup installation
fusebulbs anaconda setup installation

8. Click Finish to complete installation.

fusebulbs anaconda setup installation

Writing Python Code.

Notepad, Notepad++ or any text editor:- let us write a simple python code and run it through the command line.

Before we proceed to run our python code through the command line check if the environment variable path is set for python.

setting python environment variable

If writing python –version in command line return not recognized .. then path of python is set in environment variable path.

Follow following steps to set environment variable.

1>Right-click on This PC and select properties.

setting python environment variable

2>Click on Advanced system settings

setting python environment variable

3>Click on Environment Variables.

setting python environment path variable

4>Select path under System Variables and click on Edit.

setting python path environment variable

5>Select New and insert path where you have installed Anaconda. In my case, it’s C:\Users\HP\anaconda3.

After setting the environment variable you can check if it was set properly using the command python –version in the command line. The Python version on my PC is 3.7.6.

python version

I have written a simple python code in Notepad++ which takes input from the user and prints it.

print("Hello friend")
name=input("Please enter your name")
print("Your name is"+" "+name)

I have saved the file with extension .py in D:\Python_code.

python code in notepad

In order to run it using the command line go to the folder where you have saved your file and run the command python <<file name>>. In my case, I will run the command python

run python code in cmd

Now let us write the same code in Anaconda Jupyter notebook. It is much convenient and code and output are on the same screen.

In order to open the Jupyter notebook, Search for Anaconda from the Start menu, Launch the Jupyter( it will open in the browser), Select new then python 3.

Please follow following steps to start the Jupyter Notebook.

launch anaconda
python code in Jupyter notebook
launch anaconda Jupyter notebook
#code for taking input and printing it.
print("Hello friend")
name=input("Please enter your name")
print("Your name is"+" "+name)

Getting Started With Python has set your platform to start coding.

The next article will introduce you to basic data types in python.

Happy Learning.

Next:-Basic data types in Python


IT Analyst at Tata Consultancy Services. Follow @aniluvall

One thought on “Getting Started With Python”

Leave a Reply

Your email address will not be published. Required fields are marked *