About Me

header ads

How to Get Started With Python in less than hour?


In this blog, you will learn to install and run Python on your computer. Once we do that, we will also write our first Python program.

Python is an open source programming language that was made to be easy-to-read and powerful. A Dutch programmer named Guido van Rossum made Python in 1991.
Python is a good programming language for beginners. It is a high-level language, which means a programmer can focus on what to do instead of how to do it. Writing programs in Python takes less time than in some other languages.
Python drew inspiration from other programming languages like C, C++JavaPerl, and Lisp.

The Easiest Way to Run Python
The simplest way to run Python is by using Thonny IDE. 

The Thonny IDE comes with the latest version of Python bundled in it. So you don't have to install Python separately.

Follow the below steps to run Python on your computer.
  1. Download Thonny IDE.
  2. Run the installer to install Thonny on your computer.
  3. Go to: File > New. Then save the file with .py extension. For example, hello.py, example.py, etc.
  4. You can give any name to the file. But, the file name should end with .py
  5. Write Python code in the file and save it.
  6. Then Go to Run > Run current script or simply click F5 to run it.
        

Install Python Separately on your local machine

If you don't want to use Thonny, here's how you can install and run Python on your computer.
  1. Download the latest version 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 are able to run Python from any part of the computer.
  3. Also, you can choose the path where Python is installed.


Once you finish the installation process, you can run Python.

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.

We can use any text editing software to write a Python script file.

We just need to save it with the .py extension. But using an IDE can make our life a lot easier. 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.

By the way, when you install Python, an IDE named IDLE is also installed. You can use it to run Python on your computer. It's a decent IDE for beginners.
When you open IDLE, an interactive Python Shell is opened.



Now you can create a new file and save it with .py extension. For example, hello.py

Write Python code in the file, save it. To run the file, go to Run > Run Module or simply click F5.



Let us write our first program in Python

Now  we have Python up and running, 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.py

print("Hello world!")

Then, run the file. You will get the following output.

Hello world!

Congratulations! you have written your first program in Python.

As you can see, this was a pretty easy task. This is the beauty of Python programming Language.

Post a Comment

0 Comments