Language Β· sentiment
Happy or sad message?
π School maths Β· Years 4β5Number β negative numbers β Add +1 and β1 to a running total and read its sign.Maths by year β
The Case. How does an app know a review is positive? It reads the words. Let's teach a computer to feel the mood of a message.
Your tools. Two word-lists β happy words and sad words. The computer scores +1 for happy, -1 for sad.
Investigate. Press Run. The score decides: happy, sad, or in-between.
- Write a mean message and a kind one β does it agree with you?
- Real sentiment AI works the same way, just with thousands of words it learned.
your_code.py
Starting Pythonβ¦
The Reveal
Starting Pythonβ¦ (first time only β a few seconds)
ποΈ Detective's notes
Bundles your findings, chart and code into one PDF you can keep, print or hand in.
π§© How this code works
The tools it uses
- Matplotlib β your crayon box β it turns numbers into charts and pictures.
What this one does
- β’ It draws a bar chart β great for comparing amounts.
How to read it, top to bottom
- 1. Import β bring in the tools (listed above).
- 2. The data β the lists and numbers near the top. These are the bits you change.
- 3. The work β a little maths, or a loop that repeats a step.
- 4. Show it β
print(...)writes words;plt.show()draws the picture.
Use it for your own problems
- Change the numbers at the top and press Run β nothing breaks, so experiment!
- Ask your own version of the question β swap in your family, your scores, your week.
- The same tools work on any numbers β that's the superpower you're learning.
Need a hint?
Add your own words to the HAPPY and SAD sets to make the computer smarter.