Python Introduction

Python is general purpose high level, interpreted, object oriented programming language. there is initially invented by Guido van Rossum in 1991.

Python Features

There are lot of feature are support in python programming. here given few with small overview. there are as following

Keywords: This language are provide few keywords, easy to memorized those keyword and learning its concepts.

Python 2.7.12 keywords
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
Python 3.5.2 keywords
['False', 'None', 'True', 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

If you are use other version of python. then find out number of keywords using this program.

import keyword
#display keywords

This function are print the number of keyword in your python version. We can also check specific word is keyword or not using of iskeyword() function. let take one example.

#check given word is keyword or not

import keyword

#checking given keyword is valid or not

print("for :",keyword.iskeyword("for")) #True

print("in :",keyword.iskeyword("in")) #True

print("switch :",keyword.iskeyword("switch")) #False

print("this :",keyword.iskeyword("this"))#False
for : True
in : True
switch : False
this : False

Dynamic Data Type :This is most smart features of python programming. in other programming language like c,c++, java are need to define initial data type of every variable. but this language are cannot need to defined any data type of variable. for example.

#Define a variable
#Provide initial string value
info="Python Programming"

#Display type of variable

#Modified variable value


#Modified variable value

<class 'str'>
<class 'int'>
<class 'float'>

Note that single variable are work different different data type. and there are no need to define its proper data type.

Python Debugger: Debugging is a way to trace the execution flow of program and they are capable to change the execution flow. That is very useful technique to find logical error and mistake. let take one example.

#Trace execution of this program

#"for loop" to display of table of number 2
for i in range(1,11):
  print(result) #display result

This is an python code we can try to trace execution of this program. first need to save this file. save this file using any name like And open a terminal on this file location. if your are use windows OS then open cmd. note that cmd directive path are located to your file location (

After that run this program using this command "python". output of this program is this.

#command: python

after that try to run this program using debugger mode. syntax of debugging mode is like this.

python -m pdb
#-m is mode
# pdb python debugger module
# source_file is file name

so on run this program using debugger mode using "python -m pdb".

python -m pdb
> /location/
-> result=1

After that we are ready to trace out our program. there are various option are in debugging mode. so we will first view all of possible command. simply type ? (question mark) after the (Pdb). then see following options.

(Pdb) ?

Documented commands (type help <topic>):
EOF    bt         cont      enable  jump  pp       run      unt   
a      c          continue  exit    l     q        s        until 
alias  cl         d         h       list  quit     step     up    
args   clear      debug     help    n     r        tbreak   w     
b      commands   disable   ignore  next  restart  u        whatis
break  condition  down      j       p     return   unalias  where 

Miscellaneous help topics:
exec  pdb

Undocumented commands:
retval  rv


There is following option are available to use in debugging mode. first use to check list option. this are display our code. use (Pdb) list

(Pdb) list
  1   #Trace execution of this program
  2  -> result=1 
  4   #"for loop" to display of table of number 2
  5   for i in range(1,11):
  6     result=i*2  
  7     print(result) #display result

(Pdb) list are display above result. now if your are not get this result then using a ((Pdb) restart ) command.

(Pdb) restart
Restarting with arguments:
> /location/<module>()
-> result=1

after that use ("n") command that are execute next instruction

(Pdb) n
> /location/<module>()
-> for i in range(1,11):
(Pdb) n
> /location/<module>()
-> result=i*2
(Pdb) n
> /location/<module>()
-> print(result) #display result
(Pdb) n
> /location/<module>()
-> for i in range(1,11):

In this example uses 4 time 'n' (next) option. similarly we can also print variable value also. see example.

(Pdb) print(result)

This was an simple example most of case problem is complex so similar way we can find out logical error and trace execution flow of any code.

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment

© 2021,, All rights reserved