Sunday 20 September 2015

About Python

             Python is a high level programming language.Python is intended to be a highly readable language.Python uses white space indentation.Python programming language is more powerful and is often comparable to Perl,Ruby or Java.
Readability of syntax is a distinguishing factor of Python.Python is available for all major operating systems: Windows, Linux/Unix, OS/2, Mac.Python is friendly and easy to learn.

          Comparing to Java,Python programs are 3-5 times smaller than java prog's.Python is dynamic typed language.Python programmers don't need to waste time in declaring variable types as in java.

          List is one of the Data Structure used in Python.Main feature is LIST COMPREHENSION.
Python supports a concept called "list comprehensions". It can be used to construct lists in a very natural, easy way, like a mathematician is used to do.


for eg:

            >>> a=[1,2,3,4]
            # want to square each item in list a.
            >>> b=[]
            >>> for i in a:
                 b.append(i*i)
            >>> b
                [1,4,9,16]
using List Comprehension:
            >>> b=[i*i for i in a]
            >>> b
                [1,4,9,16]





Python has the usual C arithmetic operators (+, -, *, /, %). It also has ** for exponentiation, e.g. 5**3 == 125 and 9**0.5 == 3.0.

The behavior of division has changed significantly over time:[61]

Python 2.1 and earlier use the C division behavior. The / operator is integer division if both operands are integers, and floating-point division otherwise. Integer division rounds towards 0, e.g. 7 / 3 == 2 and -7 / 3 == -2.




A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.

As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions. These functions are called user-defined functions.

Defining a Function
You can define functions to provide the required functionality. Here are simple rules to define a function in Python.

Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).

Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.

The first statement of a function can be an optional statement - the documentation string of the function or docstring.

The code block within every function starts with a colon (:) and is indented.

The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None.





                     Currently Participated in “6.00.1x Introduction To Computer Science and Programming Using Python” from MITx (EdX). The objective of the course was to teach basic ideas of computer science and software engineering using the Python programming language.



              

My First Blog

This is for testing.