Saturday, November 24

Stay Hungry Stay Foolish - By Rashmi Bansal.

Yet another book on entrepreneurship. I have read "I have a dream" by rashmi bansal, it was about social entrepreneurs. But this book is different. I should have read this first. The book has some inspiring stories, as the book title reads

The inspiring story of 25 IIM Ahemdabad graduates who chose to tread a path of their own making.

The book has stories about entrepreneurs, their up's and down's and some take away's. Out of the 25 there were only few who were really inspiring. But lets talk about what this book gives and what i was expecting.

The good parts

1) Inspiring Stories : It is really inspiring to read about people who are self motivated and forward thinkers. For instance "Sunal Handa". The author calls him The Alchemist. This person has played various roles from a hard nosed businessman to an education entrepreneur. I think this guy is a genius an IIT'an and then studies in IIM. He is the force behind the LEM (Laboratory in Entrepreneurial Motivation). Another true inspiring story was of Vikram Talwar. Vikram Talwar had a long and distinguished career with Bank of America, almost more that 25 years. Started his entrepreneur careen in later 40's he has set up a company which is India's largest BPOs. Another one was of  Vardan Kabra of Fountainhead school, an IIT'an. He left a lucrative job to pursue his dream of starting FountainHead school.

2) Qualities : What qualities do they have to be so successful? It is passion, Risk, Courage and Forward thinking. I think every person has to have these i.e Risk taking ability and passion to do something to be successful. It is a common trait in mentioned in any/all books about successful people. 

3) To get Funded or No? This book and the stories makes me think about all the funding thing. The VC's, angel funding etc. To start your dream project, whether you need funding or no depends entirely on the type of project. And every decision about funding and money should be made when they need to be made. It cannot be planned before had. Some of the entrepreneurs choose to get funded and some like to stay away from it. So it is not really a factor or concern for all the individuals. But as i read, i realize that people who opted out of funding did spend from their pocket and some choose not to take home anything during the initial phase.

4) Big dreams and big returns : Yes all the figures are in Crores some going upto 1k Crore. The turnover of almost all the companies. All the entrepreneurs had big ideas which in turn resulted in big returns. It was very surprising to learn about these companies that started as early as in 70's - 80's and were profitable during that era. Just to be clear, i had never thought that the entrepreneurship bug had bitten this early in India. This book was an eye opener.

5) Co-founders : Most of them had a co-founder, a like minded and Risk taker. They were just luck(?) or may be smart to be together and work towards their vision. Some of their co-founders had left at an early stage, but the spark within them and the vision led them to go ahead and fulfill their dreams. To be more precise having a co-founder is important and adds a value to the overall growth of the company. What i learned from this was that you cannot be a all rounder, master of all jack kind of person to be a successful entrepreneur. No doubt there are single successful people, but if we have to go by the statistics, then a venture with a co-founder is more successful.

What i was expecting from this book.

1) Relation of these people with IIM : The book talks about 25 entrepreneur's from IIM. I was hoping at least one page be dedicated to what they learned from IIM. How each person credits their success to his/her alma mater. Did IIM have anything to do with their entrepreneurship or for that matter did MBA play any role in their career. The people in this book are IIM passed out from as early as late 60's. I think the book lost my interest as i was hoping to read about their IIM journeys as well.

2) Details on the start of the business: I was hoping if more insights be given on what exactly happend in the initial phase of the business in each entrepreneurs career. More information such as their thoughts, how did they go about setting a team, what was their thought about putting their own money. Minutely small details about the initial phase was kind of missing. The book talked about the success and turnover in crores, but what was the initial starting turnover and how they continued? I was hoping less of figures and more of the details.

Overall the book is a good read and i myself learnt a lot out of it. Especially the fact that anything can be achieved even in India if you wish to follow your dream.

Sunday, November 18

Getting Started with Django - Installing on Windows.

Initially I had started learning python with python 3.x. And the next step was to work on a web application. Django being the most popular, I jumped into installing it.

Note : Django does not work with python 3.x. It only supports python 2.x
You can read about it in their FAQ's here (

I tried running Django 1.4 on python 3 but since it does not support python 3, will not discuss the issues i faced. I then uninstalled python3 and then installed pyhon2.7.3

After installing python2.7.3, I updated my Environment Variables.
I then got the Django folder extracted and stored it in C: drive. Through the command prompt, I followed below steps to install Django.

C:/>cd Django-1.4.2
C:/Django-1.4.2>python install

The above command installed Django on my python directory in Lib/Site-Packages folder. Also it created a in the python scripts folder.

After installing I checked if django was installed correctly? For that get into the python interpreter in command prompt, i.e type python in your command prompt and then type import django. If no error, then django is installed correctly.

I then created a path variable for python scripts folder, so that the script could be run from anywhere. Also created a path for django/bin folder in the environment variable. When i tried to create a django project it showed a help menu. Any command would return a help menu of django, which is not an expected output.

See below screenshot.

After a lot of googling and stackoverflow, the django path to create a project did not work and hence, i had to settle with using the absolute path to my django script as below.

F:/> cd projects/python
F:/projects/python>F:/python27/Scripts/ setupproject mysite

The above script executes and it creates the required mysite project in the directory.

However, i was looking for a possible solution so that i don't have to use the absolute path to the django folder to create my django projects. It appears that in windows, the issue could be with the way registry is stored. A little bit of stackoverflow got me to this helpful link.

I then immediately checked my registry entries using the windows regedit.exe command. Checked both python.exe unders applications folder and .py entry for the correct path. python.exe had the correct entry which is

"F:\Python27\python.exe" "%1" %*

However the .py folder in regedit did not show correct value. It showed

"F:\Python27\python.exe" "%1" //Wrong!

Which is wrong. I updated the .py entry using the FileTypesManager software and then tried again to see if the django-admin command worked.

F:\Projects\Python> --version

Friday, November 16

Python program about a Risk Board game.

In the Risk board game, there is the situation where the attacker rolls 3 dice while the defender rolls 2 dice. To determine the outcome, the highest die of each player is compared, followed by the next highest die. For each case, the attacker's die has to be higher than that of the defender to win. The loser will lose 1 army in each case.
The closest solution i could write was as below. There might be other better pythonic way of doing it.

def RiskGame(attacker, defender):
    deff = 0
    atta = 0
    attacker.sort(reverse = True)
    defender.sort(reverse = True)
    for i,j in zip(attacker,defender):
        if(i > j and i != j):
            deff = deff + 1
            atta = atta + 1
        if(atta != 0 and deff != 0):
           print ("Attacker loses %d army and defender loses %d army." %( atta, deff))
        elif(deff == 0 and atta != 0):
           print ("Attacker loses %d armies." % atta)
        elif(atta == 0 and deff != 0):
           print ("Defender loses %d armies."  % deff)

The last if else condition seems to be wrong grammatically, as what would happen if more that 1 army is lost?

RiskGame([1,2,7], [1, 5])
#'Defender loses 2 armies.'
RiskGame([6,2,6], [6, 6])
#'Attacker loses 2 armies.'
RiskGame([1,4,1], [1, 2])
#'Attacker loses 1 army and defender loses 1 army.'

Monday, November 12

Digital Fortress by Dan Brown.

A techno-thriller. Digital fortress is a very good read.  It is simple yet amazing and considering the fact that it was published in 1998, it is way above standard. I got the chance to read it recently. Dan Brown is one of the best fiction writer and all his novels are highly appreciated. Reading this book he has got himself a new fan.

Just the time when it was an Internet boom, the author came out with a novel relevant to that era. I am quite sure, the author must have done a tremendous amount of research, as he was able to convince the audience about the topic, about cryptography, about super computers.
The topics covered by the author, are highly convincing, very well defined for people to understand and the story is streamlined from even though the events occur in different places among different characters.

NSA (National Security Agency) has a code breaking super computer program called TRANSLTR which breaks decrypts code and helps secure any terrorist activities. It is claimed to take maximum of 10 minutes to break any code. It is so powerful. However, it cannot break a complex code - DIGITAL FORTRESS - and hence Commander Trevor Strathmore calls in Susan Fletcher, the head cryptographer, to crack it. Digital Fortress algorithm is written by one Ensei Tankado, a former NSA employee who became displeased with the NSA's intrusion into people's private lives. Strathamore tries to be clandestine about the whole situation. Tankado is about to auction the algorithm on his website, but eventually dies in what appears to be a heart attack. Strathamore learns that the key to unlock the algorithm is hidden in ring which tankado gives it away to a person on his last breath.

Strathmore asks David Becker (Susan's fiancé) to travel to Seville and recover a ring that Tankado was wearing when he died. David obliges to strathamores request, but later realises how deep this is. The ring exchanges a lot of hands and David tries anything and everything to recover it.

Dan brown has a very unique style, and the story uncovers very slow, with a lot of shocker of course. Later in the story there are lot of twists and turns. It turns out Ensei Tankado had something different in store and so did Strathamore.

Thursday, November 8

Python program to Check if a Year is a leap Year.

A leap year is divisible by 4, but not by 100, unless it is also divisible by 400.

def LeapYear(yr):
if(yr % 4 == 0 and yr % 100 != 0 or yr % 400 == 0):
return True
return False

>>> LeapYear(2012)
True>>> LeapYear(2010)

Wednesday, November 7

Python program to print 12hr to 24hr format time.

def time24hr(tstr): 
new_time = tstr.split(":")
ampm = new_time[1]
ampm1 = ampm[2:]
hours = int(new_time[0])
if((ampm1 == "am") and (hours == 12)):
time1 = "00"+ampm[0:2]+"hr"
elif((ampm1 == "am") and (hours < 12)):
time1 = str("%02d" %hours)+ampm[0:2]+"hr"
elif((ampm1 == "pm") and (hours < 12)):
time1 = str(hours+12)+ampm[0:2]+"hr"
elif((ampm1 == "pm") and (hours == 12)):
time1 = str(hours)+ampm[0:2]+"hr"
print time1

Expected output

>>> 0034hr
>>> 0734hr
>>> 1934hr
>>> 1234hr