Getting Started in Python

Python is a cross-platform programming language, it means that python runs on multiple platforms like Windows, Mac OS X, Linux, Unix and has even been ported to the Java and .NET virtual machines. It is free and open-source.

Even though most of today’s Linux and Mac have Python preinstalled in it, the version might be out-of-date. So, it is always a good idea to install the most current versions.

Starting the Interpreter

To invoke it from the shell or the command prompt we need to add this location in the search path. The search path is a list of directories (locations) where the operating system searches for executables. For example, in the Windows command prompt, we can type:

set path=%path%;c:\python37 (python37 means version 3.7, it might be different in your case) to add the location to the path for that particular session. Once the path is set we can write “python” in command prompt and python will start.

We can work in python in two modes:

* immediate mode and
* Script mode

Immediate mode

Typing python in the command line will invoke the interpreter in immediate mode. We can directly type in Python expressions and press enter to get the output.

“>>>” is the Python prompt. It tells us that the interpreter is ready for our input. Try typing in 2 + 3 and press enter. We get 5 as the output. This prompt can be used as a calculator. To exit this mode type exit() or quit() and press enter.

Script mode

This mode is used to execute the Python program written in a file. Such a file is called a script. Scripts can be saved in disk for future use. Python scripts have the extension .py, meaning that the filename ends with .py.

For example hello.py To execute this file in script mode we simply write python hello.py at the command prompt.

Integrated Development Learning Environment (IDLE)

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 IDLE can make our life a lot easier. IDLE 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.

Using an IDLE can get rid of redundant tasks and significantly decrease the time required for application development.

IDLE is a graphical user interface (GUI) that can be installed along with the Python programming language and is available from the official website. We can also use other commercial or free IDE according to our preference. It is free and open-source.

Python Basic Programming Tutorial

Python Introduction     Getting started in Python Programming      Python propgramming fundamentals     Python Operators    Python If Condition     Python for loop    Python range construct      Python While loop    break and continue statements     Different looping techniques     Python List     Python String     Python Functions    Python Inbuilt Functions     Python Recursion     Using Python Library     Python Tuples     Python Dictionary     Python Sets     Python Strings     Python Exception Handling     Python Data File Handling

Visitor Counter

0142296