Code for 1st example: Perceptron