import random

class Neuron:

    def __init__(self, weights):
        self.activation = 0.0
        self.weights = weights
        self.threshold = 0.5

    def present(self, pattern):
        # make sure pattern size matches number of weights
        if len(pattern) != len(self.weights):
            print "Wrong size pattern!"
            return None

        # calculate total incoming activation
        total = 0.0
        for i in range(len(pattern)):
            total = total + pattern[i] * self.weights[i]

        # compute new activation level
        if total > self.threshold:
            self.activation = 1.0
        else:
            self.activation = 0.0

        return self.activation

#---------------------------------------------------------------------------

# create a 2-input neuron with weights of zero

n = Neuron([0.0, 0.0])

