Jump Start With Python - Part 2

NOTE: This article is a continuation of my previous article "Jump Start with Python". To read the previous article see Jump Start With Python - Part 1.
 
Applications of Python

Python is used across various verticals such as web and internet programming including software development, scientific projects, and GUI development and so on. Python provides several third-party modules and packages to support these verticals and some of them are as in the following:
  • Web and Internet Programming: Python provides various frameworks and micro-frameworks to facilitate web and internet programming such as Django, Pyramid, and Flask, Bottle respectively. Python also provides advanced content management systems, such as web2py, Plone and DjangoCMS. Python also provides a web server known as Tornado.
  • Software Development: Python provides various tools such as Buildbot and Apache Gump for compilation, testing, and automated integration. SCons for build control and version control. Trac and Roundup for issue/bug tracking.
  • Python also supports Scientific and Numerical Project Development that is generally used for research purposes and GUI Development.
Python is used by many companies such as Google, Dropbox, BitTorrent, Digg, Freshbooks, Reddit, Survey Monkey and so on.
 
Basics of Python
 
There are two programming modes in Python and they are as in the following.
  1. Shell Mode Programming: This type of programming mode is also known as Interactive Mode Programming. In this mode, the Python shell directly gives feedback/output for each statement written in it by interpreting it.

    Example


  2. Normal Mode Programming: This type of programming mode is also known as Script Mode Programming. In this mode, the Python script is stored in a file with ".py" extension and executed either in a shell or directly in a command prompt if the PATH is set.

    Example

     
Case Sensitive
  • Python is a case sensitive programming language. Identifiers are used to identify a variable, function, class, object and so on.
  • An identifier in Python can start with the letters A to Z or the letters a to z or the digits 0 to 9 or a combination of all three without any white space, however, "_" (Underscore) can be used instead of white space since Python is a white space sensitive programming language, it is a most unusual feature of Python.
  • Python does not allow special characters in identifiers such as @, $, % and so on.
  • So, Python treats "name" and "Name" as separate and unrelated entities.
White Space Indentation
  • Python is a white space sensitive programming language. It does not support curly braces to determine code blocks for functions, classes and so on, rather white space and line indentation are enforced.
  • Usually, 4 spaces are considered as an optimum indent for Python. But if 4 spaces are not used then all statements in a code block must have an equal amount of white space indentation.
  • All the statement lines with an equal amount of indentation form a code block.
  • If a line or multiple lines in a code block have different indentations from other lines in the respective code block then it will be flagged as a syntax error.

    Example

Adding Comments in Python
Python supports two types of comments and they are as in the following.
  1. Single Line Comment: This type of comment is added using "#".

    Syntax/ Example
    1. #This is a single line comment 
  2. Multiple Line Comment: This type of comment is added by placing "..." before and after the lines to be commented respectively.

    Syntax/ Example
    1. ...  
    2. This  
    3. is  
    4. Multiple Line Comment
    5. ...  
Reserved keywords in Python

There are some keywords that are not allowed to be used in Python as an identifier, constant or variable and they are the following:
  • A-M
    And
    as
    assert
    Break
    Class
    Continue
    def
    del
    elif
    else
    except
    exec
    False
    finally
    for
    from
    global
    if
    import
    in
    is
    lambda

  • N-Z
    None
    nonlocal
    Not
    or
    print
    raise
    return
    True
    try
    while
    with
    yield
These keywords are categorized as reserved because they are either used as syntax or used to perform an operation. Example: the "def" keyword is used to define a function, "for" is used to define a for loop, "elif" is used to perform an Else If logical function in Python.


Similar Articles