Skip to main content

First Python Program


  • Python comes preinstalled with an integrated development environment(IDE) known as IDLE
  • But we can install any IDE of our choice, for this we will be using sublime text
  • Click https://www.sublimetext.com/download to download sublime text
  • Double click on the downloaded executable files to install it.

Python IDLE

Python IDLE (Integration Development  Environment) is the Python IDE that comes with the Python distribution. Python IDLE is also known as interactive interpreter. It has a number of features such as text editor with syntax highlighting, smart indent and auto completion, etc., that help you work with Python quickly.
The following illustrates how to launch Python IDLE and write the Python code inside the text editor:
Launch Python IDLE
Launch Python IDLE
Launch Python IDLE
New Python Shell window will display as follows:
Python IDLE
Python IDLE
Enter the following code and press Enterthe message “Hello World” will display in the next line.
Python IDLE Hello World
Python IDLE Hello World

On Sublime Text

Once you have installed it then you have to set the path of python installation directory in environment variable. If your path is already set then you can skip this part  otherwise follow this link Setting Path . As we have already set the path so i am skipping it.

Test A simple Program

Now we will see execution of python program on Sublime Text 3. For this what we have to do is that 
  • First of all open your sublime editor.
  • Create a new file by following steps File->New File or by pressing ctrl+N .
  • Then save this file as yourfilename.py . The extension must be .py .
  • Then write your code.
Here i am taking a simple Hello World program 

Running The Code

  • Go to Tool option on menu bar and then click on  Build System and inside this select Python option.
  • Then go to Tool option and click on Build option that will execute your code. So now, on running the above code we will get the following output

Comments

Popular posts from this blog

Hitting the Python Road. To start programming with Python we need a computer (desktop or laptop) and either Python 2.x or 3 installed or smartphone. We will be working with python 3 To install Python3 on our windows computer, follow the step below: Step 1: Download the Python 3 Installer Open a browser window and navigate to the  Download page for Windows  at  python.org . Underneath the heading at the top that says  Python Releases for Windows , click on the link for the  Latest Python 3 Release - Python 3.x.x . (As of this writing, the latest is Python 3.6.5.) Scroll to the bottom and select either  Windows x86-64 executable installer  for 64-bit or  Windows x86 executable installer  for 32-bit. (See below.) Sidebar: 32-bit or 64-bit Python? For Windows, you can choose either the 32-bit or 64-bit installer. Here’s what the difference between the two comes down to: If your system has a 32-bit processor, then you shou...