Learn
Perceptron
Step 1: Weighted Sum

Great! Now that you understand the structure of the perceptron, here’s an important question — how are the inputs and weights magically turned into an output? This is a two-step process, and the first step is finding the weighted sum of the inputs.

What is the weighted sum? This is just a number that gives a reasonable representation of the inputs:

$weighted\ sum = x_1w_1 + x_2w_2 + ... + x_nw_n$

The x‘s are the inputs and the w‘s are the weights.

Here’s how we can implement it:

1. Start with a weighted sum of 0. Let’s call it weighted_sum.
2. Start with the first input and multiply it by its corresponding weight. Add this result to weighted_sum.
3. Go to the next input and multiply it by its corresponding weight. Add this result to weighted_sum.
4. Repeat this process for all inputs.

### Instructions

1.

Create a variable called weighted_sum to hold the value of the weighted sum and set its starting value to 0.

Return weighted_sum outside the for loop.

2.

Let’s go through each input-weight pair and find the weighted sum using indexing.

Delete the pass statement inside the for loop. For each iteration in the loop, find the product of the input and weight at index i, add the result to weighted_sum, and store it back in weighted_sum to update the value of weighted_sum.

3.

Outside the Perceptron class, after the Perceptron object cool_perceptron has been created, print out the weighted sum for the inputs [24, 55].

What is the weighted sum?