Some Basics of Python

Python is an object-oriented programming language.

Some features of Python are:

  • Dynamic typed- i.e. no type declaration is needed.
  • Automatic memory management(automatic garbage collection)- i.e. free spaces are automatically recycled.
  • First class function support- i.e. functions can be passed as arguments of a function.
  • Higher order functions- i.e. f(g(x)) is a classic example.


  • eg: a=[1,2,’h’,4,6,3]
  • list is generic, i.e. different type of element can be the content of a list
  • a[3:5] creates a slice from a, i.e. [4,6]
  • b=a assigns the address of a to b not values


  • similar to list, in case of accessing elements using indices
  • different from list because tuple is immutable, i.e. item in a tuple cannot be changed
  • eg: a=(1,2,3)


  • a collection with each value associated with a key
  • value can be accessed using the key
  • eg: a={‘s’:1,’t’:2,’u’:3}

Some Commands

  • help()– gives the manual entry
  • dir(a)- lists functions applicable on object a
  • range(9)- gives a list containing values from 0 to 9
  • map(f,x)- gives a list with values obtained by applying function f on list x
  • filter(f,x)- gives a list of x which returns non-zero values from function f

Some Additional Points

  • To make a python program executable with its name, we have to add the following line on left most top of our program and then make the file executable using ‘chmod +x

#! /usr/bin/python

  • Last printed expression is assigned to ‘_’, i.e.


24 is assigned to _

_+2 gives 26


About Odol Shinu

I've completed my B Tech in Information Technology in 2010 from Government Engineering College Sreekrishnapuram Palakkad under Calicut University.

Posted on August 26, 2010, in Python. Bookmark the permalink. 1 Comment.

  1. that was really a quick revision of pyhon basics

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: