In this tutorial, you will learn how to install and run Python on your computer. When we do that, we will also write our first Python program.
What is Python?
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.
It is used for:
- web development (server-side),
- programming development,
- system scripting.
Python is a cross-platform programming language, which implies that it can run on numerous stages like Windows, macOS, Linux, and has even been ported to the Java and .NET virtual machines. It is free and open-source.
Despite the fact that the vast majority of the present Linux and Mac have Python pre-introduced in it, the adaptation may be obsolete. In this way, it is consistently a smart thought to introduce the most current version.
The Easiest Way to Run Python
The easiest way to run Python is by using Thonny IDE.
The Thonny IDE accompanies the most recent variant of Python packaged in it. So you don’t need to install Python separately.
Follow the following steps to run Python on your pc.
1. Download Thonny IDE.
2. Run the installer to install Thonny on your PC.
3. Go to: File > New. and then save the file with .py extension. For instance, hello.py, example.py, and so on.
You can give any name to the document. In any case, the document name should end with .py
4. Write Python code in the file and save it.
5. Then Go run> Run current script or essentially click F5 to run it.
Install Python Separately
If you don’t want to use Thonny, here’s the manner by which you can install and run Python on your PC.
1. Download the latest versi0n of python.
2. Run the installer file and follow the steps to install Python
During the install process, check Add Python to environment variables. This will add Python to environment variables, and you can run Python from any piece of the computer.
Also, you can pick the path where Python is installed.
Once you finish the installation process, you can run Python.
1. Run Python in Immediate mode
Once Python is installed, typing python in the command line will invoke the interpreter in immediate mode. We can directly type in Python code, and press Enter to get the output.
Try typing in 1 + 1 and press enter. We get 2 as the output. This brief can be used as a calculator. To leave this mode, type quit() and press enter.
2. Run Python in the Integrated Development Environment (IDE)
We can use any text editing software to write a Python script file.
We simply need to spare it with the .py expansion. Be that as it may, using an IDE. IDE is a bit of software that gives valuable features like code hinting, syntax structure featuring and checking, file explorers, etc. to the programmer for application development.
By the way, when you install Python, an IDE named IDLE is also installed. You can use it to run Python on your PC. It’s a decent IDE for learners.
At the point when you open IDLE, an intuitive Python Shell is opened.
Presently you can make another file and save it with .py extension. For instance, hello.py
Write Python code in the file and spare it. To run the record, go to Run > Run Module or essentially click F5.
Your first Python Program
Since we have Python fully operational, we can write our first Python program.
Let’s create a very simple program called (Hello World). A “Hello, World!” is a simple program that outputs (Hello, World!) on the screen. Since it’s a very simple program, it’s often used to introduce a new programming language to beginners.
Type the following code in any text editor or an IDE and save it as hello_world.py
Then, run the file. You will get the following output.
Congratulations! You just wrote your first program in Python.
As you can see, this was a pretty easy task. This is the beauty of the Python programming language.
Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your photos and creative projects with us.