Classes in Python

There are loads of content and age old story telling way of explain classes , I take it the nerdy way and explain on the technical part of it , in this post .

Defining a class

class ClassName:

{statement-1}

.

.

.

{statement-N}

The statements can be simple statements or it can be methods .Normally the contain methods.

Class Objects:

These supports ===> attribute references and instantiation

To understand , those two lets consider a simple class definition :

I/O in Python

Reading or Writing to an I/O device is very much easier than reading Human mind!

The first on amongst the many functions in Python which helps in I/O is raw_input()

raw_input(); the name itself suggests , the input is in the raw format , that is it's simply returns the string read from the user {ending with new line char}. An argument to it , is displayed as a prompt before the user enters the data.

Ex :

print raw_input('What is your name?')

o/p : What is your name ? { waits until user types and hits enter }

Modules in Python

To create a Modules in Python, you use the def keyword, followed by the function name and argument list, and a colon to begin the function body.

General Syntax :

Arrays in Python

Variables can be organized in a particular pattern called Arrays .

There are four basic types of arrays :
  1. List
  2. Tuples
  3. Dicitionary
  4. Sets

LIST :

Easy Math with Python

Simple math with python , is as easy as counting your fingers ;0)

Basic operations : The reference are been linked to wikipedia

Variables in Python

Variables , can be considered as cups , which can had different things , it may be water , juice , or rather anything you like.

To be more technical , a variable is a name that may be bound to a value , and need not remain the same.

They can be numerical , char , strings , combination of them , interestingly Python also supports complex numbers ! {P+iJ}

Stepping into Python

What is Python ?
You guessed it wrong , if you are thinking of this :


Simple Script

I had not written , something colorful like this from a long time , have tried to tie up all the basics in a single code.
Say i name it as fun.sh , and execute it , lets see what happens :O)


#!/bin/bash


# Variable(s)
user="";

# Function,can be defined without the function keyword !!

Functions in Shell Scripts

Functions are easy to define in scripting :

function function_name
{



}

How to shell script?? Where to script??

The best way is to get any flavor of UNIX .
You can just do it in terminal or go for more attractive GUI like : geany

Alternatives for other OS :

1.cigwin : cygwin
2.mks : mks
3.winbash : winbash