Getting started with Python
- Python is a general-purpose interpreted, interactive, dynamically typed, white-space-sensitive, object-oriented and high-level programming language.
- It was created by Guido van Rossum from 1985- 1990.
- Python is open-source, so Python source code is also available under the GNU General Public License (GPL).
Features of Python
- Easy to Understand: Python has a few keywords, clearly defined syntax and clear and simple structure that makes it easy to learn and understand.
- Easy to Maintain: Python code is easy to maintain since it is easy to learn and understand.
- Broad Library: Python has a broad standard library that is portable and cross-platform compatible.
- Portable: Python has the ability to run on a variety of hardware platforms and provide the same interface and functionality across all the platforms that makes it portable.
- Interactive: Python supports GUI interfaces across all the platforms including Windows, MAC, Linux and so on that makes it interactive and allows interactive testing and debugging of Python code.
- Extendable: Low-level programs can also be added to Python code to enhance the functionality of code and make it more efficient and makes Python extendable.
- Scalable: Python provides better structure and support for large programs; that makes it scalable.
- Database Support: Python can be used along with major commercial databases available today.
- Integration: Python can easily be integrated with other programming languages, like C, C++, C#, Java and so on.
- Garbage Collection: Python supports automatic garbage collection.
- Multiple Implementations: It can be used as a scripting language or can be compiled to byte-code for building large applications.
- Programming Support: It supports both functional and structured programming methods as well as Object-Oriented Programming (OOP).
- Dynamic Type Checking: It provides very high-level dynamic data types and supports dynamic type checking.
Setting up a python environment
Getting and Installing Python
The latest version of Python can be downloaded by
Click Here.
Python is available across various operating systems including Windows, Microsoft DOS, Mac OS, Linux/Unix, Solaris, VMs and so on.
Setting Path (Windows)
There are two different ways to set the path, temporary and permanent (System Variables).
Temporary Path Set: This type of path set is done using the command line in a command prompt. The description of that is as in the following.
Figure 1: Temporary Path Set
Permanent Path: This type of path set is done by defining a new "System Variable" under Control Panel > System and Security>System > Advanced System Settings. The description of it is as in the following:
Figure 3: Permanent Path
Editor/IDE
Python comes with a default editor called IDLE but to facilitate more functional programming, I suggest using Notepad++, Komodo IDE or JetBrains PyCharm for programming Python as well as deploying projects in it.
Writing your first program in Python
The structure of a Python program is as follows.
Sample Program
- #First program in Python
- Print(“Welcome to Python Programming”)
- #Varibale
- x=”Hello World”
- print(x)
Output
Welcome to Python Programming
Hello World
Source
Figure 4: Source
Output
Figure 5: Output