Sitemap
Analytics Vidhya

Analytics Vidhya is a community of Generative AI and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

How To Get Started With Python?

--

Python is a free and open source, cross-platform computer language.

What is meant by cross-platform? It means, Python can be run on multiple platforms like Windows, macOS, Linux and also has been ported to the JAVA and .NET virtual machines.

Most of today’s Linux and Mac have Python pre-installed in it. But the version might be out-of-date, therefore it is always a good idea to install the most current version.

Install Python

1.Download the latest version of python.

Press enter or click to view image in full size
Download Python | Python.org

2.Run the installed file and follow the process to Download Python.

During the process, you have to check Add Python to environment variables, which is able to add Python to environment variables and allow you to run Python from any part of the computer.

Also you are able to change the path where Python will be installed.

Press enter or click to view image in full size
Advanced Options you can have during the process of installing Python

Finally, just by clicking the Install button Python will automatically be downloaded to your computer.

Press enter or click to view image in full size
Installing Python

Once you finish the installation process you can run Python on your computer. There are two main ways you can run Python.

1)Run Python In Immediate Mode

Get Nirushi Wijesiri’s stories in your inbox

Join Medium for free to get updates from this writer.

Open the command prompt on your computer and type python then press enter. You will be able to see the version of Python you have installed into your computer and also it will invoke the interpreter in immediate mode.

Press enter or click to view image in full size
Python in immediate mode (1)

Here we can type in Python code and press enter to get the output. Most of the time this will be used as a calculator. Try type 2+2 and press enter. You will see that it shows 4 in the next line.

Press enter or click to view image in full size
Python in immediate mode (2)

By typing quit() and pressing enter you can exit this mode.

Press enter or click to view image in full size
Python in immediate mode (3)

2)Run Python In The Integrated Development Environment (IDE)

IDE is a piece of software that provides useful features like code hinting, syntax highlighting and checking, file explorers, etc. to the programmer for application development.

When you install Python, the Python IDE is also automatically installed named IDLE. You can use it to run Python programs on your computer.

Trust me, this is so EASY!!!

when you open the Python IDLE, an attractive Python shell will open which is very decent for beginners.

Press enter or click to view image in full size
Python IDLE | Python Shell

Python shell is more like the command prompt. It can also be used as a calculator. Try below examples and see how easy it is.

Press enter or click to view image in full size
Python shell as calculator

It’s time to write your first Python program.

Click on the “File” button which is in the top of the Python shell. It will open a blank file and type the following statement inside of it.

print("Hello World!")

After that, save the file in any name but you must save it with the .py extension in the end. For instance, I’m going to save my file as “Hello.py” .

Press enter or click to view image in full size
Hello.py file

To run the file go to Run > Run Module or simply press F5. Then you will see the output of the particular file. According to our Hello.py file, it prints Hello World! in the IDLE.

Press enter or click to view image in full size
The output of the Hello.py file

Congratulations!!! You just wrote your first program in Python!

As you can see this is really easy and less number of rules. You can guess the output just by reading the program. This is the beauty of Python programming.

--

--