Python Introduction:
- Python is a powerful high-level, object-oriented programming language created by Guido van Rossum.
- It has simple easy-to-use syntax, making it the perfect language for someone trying to learn computer programming for the first time.
- This is a comprehensive guide on how to get started in Python, why you should learn it and how you can learn it.
Python Programming Basics :
Before Enter into the Python Basics lets get familiarized with the language first
Python is a general-purpose language. It has wide range of applications from Web development (like: Django and Bottle), scientific and mathematical computing (Orange, SymPy, NumPy) to desktop graphical user Interfaces (Pygame, Panda3D).
The syntax of the language is clean and length of the code is relatively short. It's fun to work in Python because it allows you to think about the problem rather than focusing on the syntax.
Python is a fairly old language created by Guido Van Rossum. The design began in the late 1980s and was first released in February 1991.
History of Python:
In late 1980s, Guido Van Rossum was working on the Amoeba distributed operating system group. He wanted to use an interpreted language like ABC (ABC has simple easy-to-understand syntax) that could access the Amoeba system calls. So, he decided to create a language that was extensible. This led to design of a new language which was later named Python.
Why the name Python?
Rossum was fan of a comedy series from late seventies. The name "Python" was adopted from the same series "Monty Python's Flying Circus".
Features Of Python:
- A simple language which is easier to learnPython has a very simple and elegant syntax. It's much easier to read and write Python programs compared to other languages like: C++, Java, C#. Python makes programming fun and allows you to focus on the solution rather than syntax.If you are a newbie, it's a great choice to start your journey with Python.
- Free and open-sourceYou can freely use and distribute Python, even for commercial use. Not only can you use and distribute softwares written in it, you can even make changes to the Python's source code.Python has a large community constantly improving it in each iteration.
- PortabilityYou can move Python programs from one platform to another, and run it without any changes.It runs seamlessly on almost all platforms including Windows, Mac OS X and Linux.
- Extensible and EmbeddableSuppose an application requires high performance. You can easily combine pieces of C/C++ or other languages with Python code.This will give your application high performance as well as scripting capabilities which other languages may not provide out of the box.
- A high-level, interpreted languageUnlike C/C++, you don't have to worry about daunting tasks like memory management, garbage collection and so on.Likewise, when you run Python code, it automatically converts your code to the language your computer understands. You don't need to worry about any lower-level operations.
- Large standard libraries to solve common tasksPython has a number of standard libraries which makes life of a programmer much easier since you don't have to write all the code yourself. For example: Need to connect MySQL database on a Web server? You can use MySQLdb library using import MySQLdb.Standard libraries in Python are well tested and used by hundreds of people. So you can be sure that it won't break your application.
- Object-orientedEverything in Python is an object. Object oriented programming (OOP) helps you solve a complex problem intuitively.With OOP, you are able to divide these complex problems into smaller sets by creating objects.
Installed and Run Python in Windows:
Go to Download Python page on the official site and click Download Python 3.6.0 (You may see different version name).
- When the download is completed, double-click the file and follow the instructions to install it.When Python is installed, a program called IDLE is also installed along with it. It provides graphical user interface to work with Python.
- Open IDE, copy the following code below and press enter.
print("Hello, Vijaykumar")
print("Hello, Vijaykumar")
Example Programs Using Python:
# Written By V.Vijaykumar# Python code to reverse a string# using loop def reverse(s):str = i + strstr = "" for i in s: return strprint ("The original string is : ",end="")s = "Vijaykumar" print (s)print (reverse(s))print ("The reversed string(using loops) is : ",end="")
Output:
The original string is : Vijaykumar
The reversed string(using loops) is : ramukyajiV
Explanation : In above code, we call a function to reverse a string, which iterates to every element and intelligently join each character in the beginning so as to obtain the reversed string.