An essential part of modern evolution and population biology is knowing how to program. By being able to write scripts one is able to analyze data in a way of ones choosing as opposed to having to rely on someone else's program. This can also be used to quickly manipulate sequence files without having to go in and change them manually. Next week I'm going to learn how to use a powerful database program called BIONUMERICS, for this I need to understand the programming language Python. I have been teaching myself it over the last few weeks and i wanted to publish the first real program i wrote myself. This program is just a bit of fun really, basically you are asked to pick a number between 1 and 100 and then the computer will try and guess, in the fewest attempts what that number is. once the computer has guessed then you will have to guess the computers number. Whomever guessed it in the least attempts wins.
Python is a really powerful language and can be obtained from (http://www.python.org), I would advise learning how to use python as not only is it useful but quite fun too. There is lots of support for biologist and some specific verions of python with useful modules in like scipy (http:// www. scipy.org) and biopython (http:// www. biopython.org).
print "\t\t\tWelcome to \"Guess My Number\"!"
print "\nThink of a number between 1 and 100."
print "I will try to guess it in as few attempts as possible.\n"
the_number = input ("Enter the number: ")
#the computer guesses the number using the random function
guess = random.randrange(100)+1
tries = 1
while (guess != the_number):
if (guess > the_number):
print "I chose", guess, "Wrong!!! The number is Lower ..."
guess = random.randint(1, guess-1)
print "I chose", guess, "Wrong!!! The number is Higher ..."
#setting limits to guesses
guess = random.randint(guess+1, 100)
tries += 1
print "I guessed it! The number was",the_number
print "I got it in ", tries, "tries!\n"
#set intial values
computer_number = random.randrange(100)+1
human_guess=int(raw_input("take a guess"))
#human_guess = loop
while (human_guess != computer_number):
human_guess = int(raw_input("take a guess:"))
human_tries += 1
print "you guessed it! The number was",computer_number
print "you got it in ", human_tries, "tries!\n"
print "computers win"
raw_input ("To end press