Python Tutorial : Part 1 – Introduction

Python Tutorial for beginner : Introduction :

What is Python?
Python is an easy to learn, interactive, object-oriented and open-sourced (under GPL license) programming language.
It was created by Guido van Rossum during 1985- 1990.

Installation : 
Many UNIX and LINUX distribution already include a recent version of python. You can open one terminal and type “python” to check if it is installed or not.
Latest versions of python 2/ python 3 can be downloaded from
(In this tutorial we are going to use python2.x as most of the Linux and mac OS are currently using python2.x as default)
Download and Install python2.x from the above link on your system.

Basics :
We can use Interactive mode or Script Mode in python programming:

  1. Interactive Mode: Type “python” on Terminal and Hit enter. Next type “print “Hello World” “, you will get the outputs like following:
    Python2.7.10 (default, May 08 2017, 19:42:47)
    [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print "Hello world"
    Hello world
  2. Script Mode Programming: Create one file and write the following:
    print "Hello, Python!"
    Next, you can run this script from the terminal like “python test_python.pyOutput will be:
    Hello, Python!
Python Keywords:
Keywords are lowercase reserved words that cannot be used as variable, constants or as anything. Following are the list of keywords currently python 3.3 contains:  else, import , pass, assert , raise, in , except, break, yield, or, if, elif, as, with, not ,global, del, and, while, nonlocal, from, def, True, try, lambda, for,continue, None, class, finally, is , False and return.
Python Identifiers:

“Identifier” is a name used to identical class, variable, functions etc. Following rules should be followed while creating an identifier:

  1.  Identifier is a combination of lowercase (a to z), uppercase (A to Z), digits (0 to 9 ) and underscore ( _ ) . You can create an identifier with any combinations but remember: it should not start with a digit. 
  2. Only class name starts with a uppercase letter.
  3. Python Keywords we have seen above cannot be used as an identifier.
  4. If an identifier has : 
    1. One leading underscore : private identifier
    2. Two leading underscore: strongly private identifier
    3. Two trailing underscore: special name
Indentation : 
Unlike C or Java, we cannot use braces to indicate code blocks in python. In python, code blocks are defined by their indentation. No. of indentation may be different, but it should be consistent throughout that block.You cannot use one tab for the first line and four whitespaces for the second line.
Statements : 
In python, instructions that the python interpreter can execute are known as statements. e.g. count =10 is an assignment statement. If a newline character is received, it is considered as the end of a statement. 
e.g. count = 1+2+3+4+5
Multi-Line statements: 
Can we write the above statement in multi lines. 
The answer is yes
Explicit line continuation : Using line continuation character ( \ )
Count = 1+\

Implicit line continuation : Statements inside {},() or [.] are not required to use the line continuation character.

Count = [ 1+
We can also put multiple statements on a single line using a semicolon :
Count =1 ; var1 = 2; var2 = 3
Comments in python: 
Comments are really important to any programming language. In python, hash symbol (#) is used to start a comment. For multi-line comments, you can use hash on each line or triple quotes ( ‘ ‘ ‘ or “ ” ” )
#this is a comment
Count = 10 #this is also a comment 
“”” This is a 
Multi line comment “”"

 That’s it for this tutorial on Python. We will cover some more new topics from next tutorial. Don’t forget to like codevscolor facebook page and join our newsletter 🙂


Leave a Reply