Bird
0
0

You want to build a simple neural network that takes three inputs and produces one output by multiplying each input by a weight and summing them. Which Python code correctly implements this?

hard📝 Application Q8 of 15
AI for Everyone - How AI Models Actually Work
You want to build a simple neural network that takes three inputs and produces one output by multiplying each input by a weight and summing them. Which Python code correctly implements this?
Aoutput = inputs * weights
Boutput = sum(i * w for i, w in zip(inputs, weights))
Coutput = sum(inputs + weights)
Doutput = [i + w for i, w in zip(inputs, weights)]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the neural network output formula

    Output is sum of each input multiplied by its weight.
  2. Step 2: Match code to formula

    output = sum(i * w for i, w in zip(inputs, weights)) uses zip to pair inputs and weights, multiplies pairs, then sums them.
  3. Final Answer:

    output = sum(i * w for i, w in zip(inputs, weights)) -> Option B
  4. Quick Check:

    Correct weighted sum code = output = sum(i * w for i, w in zip(inputs, weights)) [OK]
Quick Trick: Use zip and sum for weighted sums in neural nets [OK]
Common Mistakes:
  • Trying to multiply lists directly
  • Adding lists instead of multiplying
  • Returning list instead of sum

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AI for Everyone Quizzes