Getting Started With Python

Building blocks of Python language

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 essential languages. It will help to install Anaconda and run your first python program.

Why Python?

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

2Hundreds of Python Libraries and Frameworks:-Before I explain this, I want you to understand what is Library and Framework are.

The library is a bunch of code already written for you.

For Example:-

The statistics library contains code (functions) for calculating mathematical statistics of numeric data like mean, median, mode, etc. To use a library and its methods, you need to import it into your code.

# 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) 

Instead of calculating the mean, You just need to pass your data to the mean() function of the statistics library. It saves your time and effort.

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

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

  • The 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:-Big Data, Machine Learning, Cloud Computing, etc., use Python extensively. Machine learning projects like TensorFlow, OpenCV for computer vision, etc., use Python libraries.

Last but not least, it is one of the most sought-after programming languages in the IT world.

Stepwise guide to installing Python

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

  1. Search for Anaconda in the search engine and click on Installation.

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

3. Click on Download the Anaconda Installer.

4. Click on the Link as per your system configuration. In my case, I will select a 64-bit installer.

6. Double Click on the Installation .exe file.

7. Click Next.

8. Read the licensing terms and click “I Agree”.

9. Select an install for “Just Me” unless you’re installing for all users (which requires Windows Administrator privileges) and click Next.

10. Select a destination folder to install Anaconda and click the Next button.

8. Click Finish to complete 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 the python path is not set in the environment variable.

Follow the following steps to set the environment path. An environment path is not mandatory if you use the Anaconda Jupyter notebook for writing python code.

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 the 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 the 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

1 thought on “Getting Started With Python”

Leave a Comment

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