Friday, October 25, 2013

Python Part 2: Learn a Programming Language.. dang it!

Continuing in my series where I try to convince you to learn a programming language... let me just say that Python can be used for a large number of very useful analytical things... like analyzing sales data, analyzing survey data, and much, much more!  

Without further ado, here is Part 2, to the "Quick Python Training by Harlan" series.
Here's the link to part 1... (prerequisite is required): http://tytusblog.blogspot.com/2013/10/why-everyone-should-learn-programming.html

This week you will learn: Intermediate Python...   Libraries, Dictionaries, Lists, Time, and more.

You will also learn about files, paths, and such...  here we go!


  1. First, you will need to be able to run python from a command line... on a PC, click Start->run->CMD   then in a command shell, type cd c:\python26  <enter>  (or the path to where you installed python), then type python.exe   (you should be at the shell).  type quit() to exit the shell.
    1. on MAC, just open the terminal, and type python, and it should work.
  2. Now, we need to learn how to make a file that python can run...   from command line type:
    1. notepad hi.py (PC)  or    on mac.. do vi hi.py  
    2. in notepad type: print "Hello!" then alt-file-save alt-file-exit.  
      1. on mac, type i  then type print "Hello!", then press escape, then type :wq  <press enter>
    3. now, from your command line type python hi.py
      1. SEE THE OUTPUT! :)  you just made a python program !
  3. Okay, next let's do some FILE INPUT OUTPUT to learn about libraries.
    1. make a file called  helloname.py  that looks like this:
import sys, os, glob

from optparse import OptionParser, make_option
import csv

def main():
    help = "Read the name of person and print hello persons name"
    args = "usage: %prog -n = name"
    parser = OptionParser(args)
    parser.add_option('--path', '-n', dest='name', help='name of person')
    (options, args) = parser.parse_args()
    name = options.name

    print "Hello", name

main()

#run this with python helloname.py -n Harlan

    4.  Now, lets do some outputting to a file!   make a new file called helloname_to_out.py

import sys, os, glob

from optparse import OptionParser, make_option
import csv

def print_hello_name_to_file(name):
    afile=open("namefile.txt", 'wb')
    afile.write("Hello %s!" % name)
    afile.close()
    return afile

def main():
    help = "Read the name of person and print hello persons name"
    args = "usage: %prog -n = name"
    parser = OptionParser(args)
    parser.add_option('--path', '-n', dest='name', help='name of person')
    (options, args) = parser.parse_args()
    name = options.name

    file = print_hello_name_to_file(name)
    print "done check the file", file

main()

#run this with python helloname_to_out.py -n Harlan

   5. Time to play with time... try this file: hitime.py
import sys, os, glob
from datetime import datetime

from optparse import OptionParser, make_option
import csv

def print_hello_name_to_file(name):
    afile=open("namefile.txt", 'wb')
    afile.write("Hello %s! " % name)
    now=datetime.now()
    afile.write("It is now: %s" % now)
    afile.close()
    return afile

def main():
    help = "Read the name of person and print hello persons name"
    args = "usage: %prog -n = name"
    parser = OptionParser(args)
    parser.add_option('--path', '-n', dest='name', help='name of person')
    (options, args) = parser.parse_args()
    name = options.name

    file = print_hello_name_to_file(name)
    print "done check the file", file

main()

#run this with python hitime.py -n Harlan

   6. Okay now time for some lists!  Let's learn these in idle!  start idle in windows start->run->idle   or mac: from terminal type: idle
      #okay, now you can type stuff into idle to go along... and learn about lists
      firstlist = [1,2,3,4]
      print firstlist
      print firstlist[0]
      print firstlist[2]
      print firstlist[4]

      #now try this
      list2=[1,2,"3","hi",["a","b","c"]]
      print list2
      print list2[3]
      print list2[4]
      print list2[4][2]

  7. now then, on to dictionaries
        dict1={1:'one',2:'two',3:'three'}  
        print dict1
        print dict1[2]
        print dict1[0]
   #and an advanced one
       dict2={'numbers':[1,2,3], 'letters':['a','b','c'], 'name':"Harlan", 5:'Five!'}
       print dict2[5]
       print dict2['numbers']
       print dict2['numbers'][0]

   8. finally, lets make our own library and import it!
   #in notepad make a file called: namefromfile.py
import os
 
import os
 
def getname(afilename):
    afile = open(afilename,'r')
    namelist = afile.readline()
    names_in_list = namelist.split(' ')
    if len(names_in_list) > 1:
         name=names_in_list[1]
    else:
         name=names_in_list[0]
    return name          

   #save this, now make a new file called   hinamefromfile.py
import sys, os, glob

from optparse import OptionParser, make_option
from namefromfile import getname
import csv

def main():
    #help = "Read the name of person and print hello persons name"
    #args = "usage: %prog -n = name"
    #parser = OptionParser(args)
    #parser.add_option('--path', '-n', dest='name', help='name of person')
    #(options, args) = parser.parse_args()
    #name = options.name

    name = getname('namefile.txt')

    print "Hello", name

main()

  #run this with: python  hinamefromfile.py
 



9. OKAY HOMEWORK TIME!!!  This will require research... which is a MAJOR part of any programming language!!!  but you have the basics to do this!

first, create this file called "harlansdictionary.csv", it should contain the following
Hungry,Honkin Hungry
Angry,Mad As Hell
Happy,Gleed Myself
Sad,Sobbin Myself


Now, write a program that takes any sentence, and replaces any word found in the first column, with Harlan's version on the right.  For fun, feel free to add to the dictionary!

NOTE: you must load the dictionary fresh on each time the program runs!
HINT: you might use    import csv   (research it!)  will help a lot.
HINT2: you might use dictionaries
HINT3: you might use split() function as in today's teaching.

YOU CAN DO IT!
   


Friday, October 18, 2013

Why everyone should learn a Programming Language & How to learn Python!

I think everyone should learn a programming language.  It teaches the importance of order, of 'proper' order.  It teaches good planning skills.  It teaches discipline.  It teaches self-learning... and IT IS PRACTICAL!    You would be surprised how often it could be helpful for you to know how to program something up real quick!

So, which language should you learn? My opinion: Python!   Specifically Python 2.6.    I will be posting here in my blog a mini-series of how to learn python.  This is part 1 of 4:  Basic Python

Python Basics  "Hello World",  If I am Cool, "Hello World",  Forever "Hello World", 100 "Hello Worlds".


This whole thing should take you no more than 30 minutes....

1.  Download and install python for your MAC or PC:  (just use the installer!)
http://www.python.org/download/releases/2.6/

2. NEVER BE AFRAID TO SEARCH THE DOCUMENTATION!!!!
http://docs.python.org/2.6/index.html

3. Breeze through a few of these Python Training Slides.. (just go through quickly....  you only learn programming by doing... so go do #4 ASAP!)
http://www.slideshare.net/ahmetbulut/programming-with-python-week-1
http://www.slideshare.net/ahmetbulut/programming-with-python-week-2
http://www.slideshare.net/ahmetbulut/programming-with-python-week-3
http://www.slideshare.net/amiable_indian/introduction-to-python
http://www.slideshare.net/amiable_indian/introduction-to-python-part-two

4. Do the following code in a file for practice... and do the homework below.

print "hello world"

a=1
print a
a="b"
print a
b=5
print b
a=b
print a

message="harlan is cool"
cool=True
if cool:
    print message

cool=not cool
if cool:
    print message

cool=not cool
if cool:
    print message

dancer=True
if cool and dancer:
    print message
    

if cool or dancer:
    print message


#while True:
#    print "hello world"

#for i in range(1,101):
    #print i, "hello world"


name=raw_input("what is your name?")
print "hello %s" % name

number=raw_input("how old are you?")
if int(number) < 5:
    print "you are younger than 5"
elif int(number) < 25:
    print "you are younger than 25"
else:
    print "you are older than 25"
    

'''Homework
Due by next week... write a program that prints    ___ is an even number...
   for every number from 1 to 1000.. then asks user to put in any number
      checks if it is even, and if so.. prints  __ is an even number
       if not prints ___ is NOT an even number.
       * bonus points if you handle 0 correctly!
'''

Friday, October 11, 2013

SPIN Selling for Engineers: How to teach Engineers to Sell!

"Wow, that was so cool, it really works!" - University of Texas Engineering Undergraduate

This was the general sentiment this week when I demonstrated the SPIN Selling technique to a group of undergraduates (mostly engineering-types) who are studying entrepreneurship at The University of Texas in the 1 Semester Startup Class (now called Longhorn Startup).  I volunteered to demonstrate the approach on their very first sales call (yes they are really that far along, and I'm so proud of them!  They have overcome the first and second hurdle of entrepreneurship: 1. Selecting a Target Market.  2. Getting over their Fear.).

So what is SPIN Selling?  And why is it a great technique for Engineers?  Read on My Friends!

First, SPIN Selling is a technique originally developed by Neil Rackham.. in his book SPIN Selling.
If you don't like reading, this site has a nice summary of the book on 1 page: http://wolfram.org/writing/howto/sell/spin_selling.html

However, I'll also summarize SPIN Selling in my own words below with one major tweak: from the perspective of an Engineer trying to make his/her first sale...

  1. SPIN Selling is great for engineers because it is an easy to understand acronym: S=Situation Questions, P=Problem Questions, I=Implication Questions, N=Need-Payoff Questions
  2. One of the best approaches to sales naturally emerges by "following the process" which, following processes is easy for engineers to do.
    1. This process is one of 'connecting to the client', 'understanding their needs', and 'fitting or not fitting your product to satisfy their true needs'....   if you can connect the dots for the prospect: the sale is just a natural thing!
      1. And they'll want to buy from YOU specifically, not necessarily because your product is superior (a concept Engineers need to not focus on), but because you understand them best, and have built a rapport with them through "the process".
  3. The Process:
    1. Ask a few "Situation Questions" to get them thinking about their business, not yours: Initially on the call or in the meeting, simply ask how his/her business or life is going and uncover the specifics of their business as it might relate to your product. 
      1. Examples:  How is your business going?  How do you measure success?  What kinds of files do you use?  Who are your clients?  etc.
    2. Ask a few "Problem Questions" until you uncover a problem you might be able to solve: Basically try to uncover what problems they have (not if, we all have problems)..  Focusing on Throughput or Cost (throughput questions are ones of ability to deliver product/service, or inability to get new clients/customers)... cost is cost and headache (mental cost).  Obviously, focus on those areas which your product/service might solve...
      1. Examples: Do you feel you have plenty of clients?  Do you have any major cost problems?  Are you able to fulfill all your orders on time?  What is preventing you from being more successful today?  What gives you the biggest headaches today?
    3. Ask enough "Implication Questions" such that they agree that the problem is serious: Try to get them to see the light that the problem has real consequences.  To understand, for example, that those extra costs are cutting in to margins, which slows growth.  Or that the lack of enough customers means you are wasting resources from under-utilization.
      1. Examples: Do you agree that the lack of customers means you are under-utilizing your fixed resources?  Do you agree that the extra costs you are incurring is hitting your bottom line, and that extra cash you could have had would be useful to help you grow?  Do you agree that your headaches might be making you distracted on other issues?
    4. Ask enough "Need-Payoff Questions" such that they agree a solution has real value.  Need-Payoff sort-of restates the Implication question in such a way that a solution has real value.  Once they agree to real value... then, and ONLY THEN, can you pitch your product/service.... and it will be in their terms...  
      1. Examples: Do you agree that getting rid of that headache would let you be more productive at other more important things?   Do you agree that your increased productivity is worth real value?  In hours per day?  In Dollars per day?  Do you agree that being able to get more customers has real value?  In Dollars per Customer?  Do you agree that reducing costs impacts the bottom line directly?  In real profit dollars?
    5. Now, and only now that they agree there is real value in a potenial solution, are you permitted to pitch your idea... AND ONLY PITCH IT IF YOU CAN GIVE THE PAYOFF (or a part of it) THEY AGREED TO IN STEP 4.  If not, continue with Steps 2-4, until you can or until they hang up!
      1. The pitch should be short, just 3 slides (more on this next time): Benefits, Tech, Price.
      2. Don't talk to the slides, talk to how YOUR PRODUCT might help solve THEIR PROBLEM... And point back to those NEED-PAYOFF questions you asked.
    6. Finally, Ask a few "Qualifying Questions", and then "ASK FOR THE SALE": You need to "flip the conversation" to be more about potentially fitting them to your business....   Now, they need to SELL YOU!
      1. You truly want it to seem like buying your product/service means belonging to an exclusive club.. and only some people are PERMITTED TO BUY!
      2. You questions now are "Qualifying Questions"... here is some good ones:
        1. We want to work with 'thought leaders' and 'early adopters', how forward-thinking about new stuff is your company?
        2. It is important that we work with companies of just the right size, how big is your business?
        3. We want partners who will become our reference customers, if things we work together to solve your problems, would you be willing to be a reference customer?
        4. Alright... it seems like we might be a good fit... it also seems that OUR PRODUCT/SERVICE will really help SOLVE YOUR PROBLEM and has a REAL DOLLAR IMPACT TO YOUR BUSINESS... 
          1. ASK FOR THE ORDER!!!!
            1. How many units can we sell you today to see how well this works?  or  
            2. What size initial order can you place today to test our ability to deliver?  or
            3. Who in your organization needs to sign off on this deal?
    7. Level Up!
      1. Regardless of the answers to step 6... be sure you try to "level up".
      2. Often-times in a big sale, it takes many approvals and other folks to help decide.
      3. Leave EACH MEETING with a date/time for the next meeting and try to "level-up" the meeting....  TRY TO ATTEND ANY APPROVAL MEETINGS IN PERSON.
      4. Bring up all you have learned about their problem and the NEED-PAYOFF in REAL DOLLARS! (I hope you took notes).
And that's it my friends!
Go out and sell!  But remember, only sell IF you can make a real dollar impact... if not, trust me, you don't want them as a customer.... they won't be happy, and neither will you.




Blog Archive

Followers