// Technology · 3º ESO · Colegio Reina Sofía

Programming &
Computational Thinking

Unit 6 — Master the programming process, Scratch, App Inventor, flowcharts and artificial intelligence.

⚙️ Scratch & Programming
📱 App Inventor
🤖 AI & Smart Machines
📝 Self-assessment Quiz
1.1

What is programming?

Core definition

PROGRAMMING

Writing lines of code (instructions) to make a program or application that solves a problem or satisfies a need. We use an artificial programming language designed to give instructions to a machine with a microprocessor.

IDE

Integrated Development Environment. A tool that lets us type instructions, compile them, translate them into machine code and run the program. Examples: Visual Studio Code, Scratch, App Inventor.

💬
Many languages exist

JavaScript, Java, Python, C++, Visual Basic… Each has its own vocabulary and rules. The right choice depends on the task: a video game, an antivirus and a self-driving car each require a different approach.

1.2

The programming process

4 mandatory steps — always in order
1

Define the problem / identify a need. Be clear about the exact problem, the available data, and how you will present the solution.

2

Analyse and solve the problem. Investigate how to make the machine work with the data. Choose the most suitable programming language and study the parameters, operations and algorithms needed. Represent the logic as a flowchart.

3

Programming. Use the chosen language to write the actual code.

4

Checking and debugging. Test the program against the requirements from step 1. Fix any errors (bugs). Share if it works!

1.3

Algorithms & Flowcharts

Key concepts

ALGORITHM

A finite, ordered set of steps that solves a problem. It must have a clear start and end, and each step must be unambiguous.

FLOWCHART

A visual diagram that represents an algorithm using standardised shapes connected by arrows.

Tool recommended: Flowgorithm (free, online) — draw the flowchart and it automatically generates code in several languages.

Flowchart symbols
ShapeMeaning
OvalStart / End
RectangleProcess / action
ParallelogramInput / Output
DiamondDecision (Yes / No)
ArrowFlow of control
🛒
Example problem

A shop sells apples at €1.20/kg. Discount of 10% if over 3 kg. Calculate total price. → Data, Operations, Result.

1.4

Programming with Scratch

Scratch interface — key areas

Stage

480 × 360 px canvas where action happens. Coordinate centre at (0,0).

Sprites

Objects / characters on the stage. Each has its own routines (code).

Backdrops

Background images for the stage. Choose from library or create your own.

Blocks palette

Colour-coded blocks organised by category: Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables.

Costumes pane

Each Sprite can have multiple costumes for animation effects.

Scripts area

Drag and drop blocks here to write the program routines.

1.5

Program components in Scratch

Building blocks of any program

VARIABLES

Containers that store data — numbers, names, text — used throughout the program. In Scratch: Make a Variable in the Variables palette.

OPERATORS

Perform arithmetic (+, −, ×, ÷), generate random numbers, and check if data is correct (comparisons, boolean logic).

CONDITIONAL STATEMENTS

Run a set of instructions only when a condition is met. Found in the Control tab. Structure: if … then … else …

LOOPS

Repeat a set of instructions a given number of times or until a condition is met. Types: repeat n, forever, repeat until.

🐱
Worked example — "Cleaning up our Oceans"

A game where a diver collects plastic while avoiding a shark. Requires: a backdrop (ocean), 3 sprites (Diver, Shark, Plastic), a forever loop for the shark, conditionals for collision detection, and a variable for score.

🍎
Worked example — "Five a day!"

A catching game with a Cat sprite, falling Fruit and Cake sprites, a score variable, a FruitBasket list to track collected items, and routines for keyboard control, costume change, scoring and game-over detection.

🌐
Access Scratch

scratch.mit.edu — free, browser-based, no installation needed. Sign in to save and share projects.

2.1

Can you write programs for a mobile phone?

App Inventor overview

APP INVENTOR

A free online tool by MIT for designing and developing apps for Android devices. The programming approach is block-based, very similar to Scratch. Access at ai2.appinventor.mit.edu

Design window — 7 areas
#AreaFunction
1Menu toolbarManage projects, set language
2Window toolbarShows project name, controls windows
3PaletteComponents to build the app (by category)
4ViewerPreview the app layout on screen
5ComponentsList of elements added to the app
6MediaUpload images, audio and video
7PropertiesSet font, location, background, image…
Programming window — 3 areas

BUILT-IN BLOCKS

All program blocks organised by type: Control, Logic, Maths. Colour-coded like Scratch.

WORK AREA

Drag and combine blocks here to write the program logic.

TRASH

Drag blocks here to delete them.

📲
Deploying your app

Build → Generate QR code (.apk) → scan with your Android phone using the MIT AI2 Companion app. No cable needed.

2.2

Worked examples

Programme 1 — "My Animal Farm"
1

Problem: Create a simple app for children that shows a farm. Each animal makes its sound when touched.

2

Design: A Canvas (like Scratch's Stage). Two ImageSprites (Sheep, Hen). Background: Farm.jpg. Sound files: baa.mp3, cluck.mp3.

3

Key block: when ImageSprite1.Touched → do call Sound1.Play

4

Testing: Check, correct errors. Deploy with Build → QR code.

Programme 2 — "Get to know your region"
1

Problem: A quiz game showing famous regional monuments. 4 answer buttons + a Next button.

2

Key components: Image1 (monument photo), Label Question (question text), HorizontalArrangement1 (button row), RightWrong label (feedback), Next button.

3

Variables used: listofQuestions (ordered list), listofAnswers, listofPictures, questionNumber (tracks current question).

4

Next button logic: Clear RightWrong text → increment questionNumber → if end of list, reset to 1 → update Question label and Image.

💡
Key App Inventor concept: Lists

Lists (like arrays) store ordered data. Use select list item list … index … to retrieve a specific item. Lists are essential for quiz apps, databases and catalogues.

3.1

3D Computer Design with BlocksCAD

BlocksCAD — programmatic 3D modelling

A free browser-based tool (blockscad3d.com/editor) that uses blocks to design 3D parts — directly exportable for 3D printing. It bridges programming logic and physical fabrication.

PRIMITIVES

Basic shapes: sphere, cylinder, cube. Combined with boolean operations (union, difference, intersection).

LOOPS IN 3D

Use repeat loops to generate arrays of objects — e.g. 10 LED lens epoxy rings automatically spaced.

RENDER

Click Render to see the final 3D object. Export as .STL for 3D printing.

🔦
Worked example: LED epoxy lens

Base cylinder (r=2.9, h=1.0) → subtract offset cube for notch → add central cylinder → incorporate sphere (r=2.5, z=6.2). The program uses difference() and union() operations — the same logic as code conditionals.

3.2

Solving problems using Flowcharts (Flowgorithm)

From problem to flowchart to code
D

Data: What inputs does the algorithm need?

O

Operations: What calculations or decisions are needed?

R

Result: What should the output be?

🛒
Apple shop problem

Price €1.20/kg. 10% discount if >3 kg. The flowchart has one diamond decision block: "weight > 3?" → YES branch applies discount, NO branch does not.

// Flowgorithm → auto-generates this logic Input weight total = weight * 1.20 If weight > 3 Then discount = total * 0.10 Else discount = 0 End If total = total - discount Output "Total: €", total

Flowgorithm lets you run the flowchart step-by-step AND export it as Python, Java, C++, etc. — a great bridge between visual logic and text code.

3.3

Pandemic control simulation in Scratch

Advanced Scratch — clones, lists & data collection

A simulation of pandemic spread using Scratch's create clone of… block, a data variable called infections, and a stopwatch to measure infection rate over time.

SPRITES NEEDED

Healthy, Infected, Line, Tracker — four objects with different costumes.

CLONE LOGIC

Create 50 clones (kittens). If a Healthy clone touches an Infected one → create new Infected clone, infections += 1.

DATA LIST

A list called data records infections every 2 seconds. Export to spreadsheet for analysis.

VARIABLES

infections (integer counter), stopwatch (built-in Scratch timer). Condition: mask or no mask changes infection probability.

📊
Why this matters

This is computational modelling — the same principle used by scientists to model real epidemics. Changing the mask condition is equivalent to changing a parameter in a real scientific model. Data collected can be analysed in Google Sheets or LibreOffice Calc.

4.1

Artificial Intelligence: the smart container

What is Artificial Intelligence?

ARTIFICIAL INTELLIGENCE (AI)

The intelligence that machines possess: the ability to perceive their environment, reason, communicate and learn. AI programs don't know exactly what to do with data — they must work it out by themselves by learning patterns from examples.

MACHINE LEARNING

A branch of AI where the computer learns from labelled examples instead of following fixed rules. Used in image recognition, language translation, spam filters.

DEEP LEARNING

A type of machine learning using neural networks (layers of algorithms inspired by the human brain). Powers virtual assistants, autonomous vehicles.

IoT (Internet of Things)

Everyday objects equipped with sensors that send data to the cloud. Smart thermostats, connected waste containers, wearables.

ECO-IoT CONTAINER

A real project: smart bins that use AI + IoT to predict waste volume and optimise collection routes, reducing fuel use and pollution.

4.2

Teaching a computer to classify waste

ML project with machinelearningforkids.co.uk
1

Choose the input type: Text, images, numbers or sounds. For the waste classifier, choose text.

2

Create labels (classes): e.g. "Paper", "Plastic", "Glass", "Organic", "General". These are the categories the AI will learn.

3

Add training data: Write as many examples of each type as you can. Try for an equal number of examples per label.

4

Train the model: Click Train. The algorithm finds patterns in your examples.

5

Learn & Test → Make: Test with new inputs. If the model makes mistakes, add more training data for that class and retrain.

6

Import into Scratch: New ML blocks appear in the palette. Use them in your game to classify waste in real time.

🌍
Project: "Don't use the wrong bin!"

A Scratch game where waste falls from the top and the player places it in the correct bin. Connect the ML model so that the AI classifies the waste automatically. Add a scoreboard and a list of waste collected per bin.

4.3

Smart machines & sustainability

AI applications for a sustainable future

🌾 Agriculture

Sensors predict irrigation needs. Drones control plantations and detect pests. Autonomous robots perform agricultural tasks.

⚡ Energy supply

Predict energy needs and optimal conditions for wind/solar production. Reduces waste and improves grid efficiency.

♻️ Waste classification

AI vision systems at recycling centres classify waste faster and more accurately than humans.

🏙️ Sustainable cities

Autonomous vehicles optimise traffic flow. AI proposes alternative routes to reduce jams and CO₂ emissions.

🌿 Ecosystem monitoring

Satellite image analysis detects vegetation changes, water shortages, and invasive species early.

🏥 Healthy cities

Chatbots assist elderly people. AI analyses biological big data to predict and prevent diseases.

⚠️
Risks of AI

Loss of jobs, high energy demands to train large models, tendency to reflect the biases (race, gender, age) of their creators through discriminatory data. Critical thinking about AI systems is a key digital competence.

4.4

Circular economy & the 9 R's

Beyond recycling — the full circular model

PLANNED OBSOLESCENCE

Products deliberately designed to fail or become unfashionable quickly → drives over-consumption. Part of the linear take-make-waste economy.

CIRCULAR ECONOMY

Keeps materials in use as long as possible. Goal: zero waste, zero pollution, nature regeneration.

THE 9 R'S

Refuse → Rethink → Reduce → Reuse → Repair → Refurbish → Remanufacture → Repurpose → Recycle. In that priority order.

📦
Each of us generates ~500 kg of waste/year

Minimise single-use plastics. Reuse packaging. Buy in bulk. Before recycling, reduce — recycling still costs energy and materials.

4.5

Storing electrical energy

Why energy storage matters for renewable energy

Wind and solar are variable. To achieve climate neutrality, we need to store energy for when it's needed — not just when it's produced.

TechnologyHow it worksScale
BatteriesChemical reactions between two electrodes + electrolyte. Li-ion: phones, EVs. Ni-MH: electronics. LiPo: higher energy density.Small–large
Graphene supercapacitorsCharge in seconds, high power output. Miniaturised for wearables and IoT.Micro–medium
Superconducting magnetsNo energy loss — but need cryogenic temperatures.Large
Pumped hydroWater pumped uphill when surplus energy; released to generate electricity on demand. Most common in Europe.Grid-scale
Compressed airStore compressed air in containers; release to power generators.Grid-scale
Thermal storageStore heat or cold; convert back to electricity.Large
HydrogenBasis of fuel cells. Produce via electrolysis using renewable electricity. Energy-dense but requires renewable source.Grid-scale
5.0

Practical Activities — Unit 6

📋
Assessment note

Activities marked ★ Extended can form part of the project portfolio. Always document your process: problem definition, design decisions, testing evidence and conclusions.

01

Flowchart design challenge

Choose one of the following problems and design a complete flowchart using Flowgorithm or on paper:
(a) A program that asks for a student's mark (0–10) and outputs: Fail (<5), Pass (5–6), Merit (7–8) or Distinction (9–10).
(b) A program that calculates the area of a circle given the radius, applying a 15% surcharge if area > 50 m².
Export the Flowgorithm diagram and auto-generate the code in Python. Compare the flowchart and the code side-by-side in a brief written reflection.

Algorithms Flowgorithm Medium
02

Scratch project: Ocean cleanup game

Recreate (or extend) the "Cleaning up our oceans" game from the unit. Requirements:
· Diver sprite controlled by arrow keys (Diver routine).
· Shark sprite that always follows the diver (infinite loop + point towards).
· Plastic sprite that loops continuously with a new random costume on each cycle.
· Score variable: +1 per plastic collected. Game ends when shark touches diver.
Extension: Add a timer variable and display it on screen. Add a high-score system using a list.

Scratch Variables Loops ★ Extended Medium
03

Pandemic model analysis

Open the pandemic simulation from the unit (or recreate it). Run the simulation three times: (1) no masks, (2) 50% mask usage, (3) 100% mask usage. Export the infections data list each time. Import into Google Sheets, create a line chart overlaying the three scenarios, and write a 150-word analytical conclusion: How does mask adoption affect peak infections and infection rate? What real-world policy implications does this suggest?

Scratch Data analysis Computational modelling ★ Extended Advanced
04

App Inventor: Regional quiz app

Build your own quiz app about a topic of your choice (history, science, geography of Murcia…). Requirements:
· Minimum 8 questions stored in a listofQuestions.
· Corresponding lists for answers and images.
· RightWrong label gives immediate feedback.
· Score counter visible on screen.
· At the end, a screen showing final score and option to restart.
Deploy to a real Android device using QR code. Record a short screen-capture demo video.

App Inventor Lists Android ★ Extended Advanced
05

AI waste classifier — "Don't use the wrong bin!"

Using machinelearningforkids.co.uk, train a text-based classifier with at least 5 waste categories (Paper, Plastic, Glass, Organic, General) and 15+ examples per class. Test your model's accuracy. Then integrate it into a Scratch game where:
· Waste items fall from the top of the stage.
· The player types or clicks the correct bin.
· The ML model checks whether the waste type matches the bin.
· A scoreboard and end-of-game waste summary list are shown.
Document the ML training process with screenshots.

AI / ML Scratch machinelearningforkids ★ Extended Advanced
06

BlocksCAD: design a custom component

Design a functional 3D object in BlocksCAD using at least 3 primitives (cylinder, cube, sphere), at least one boolean operation (difference or union), and at least one loop (e.g. to repeat a pattern). Suggested objects: custom pen holder, a set of chess pawns, a parametric bracket. Export the .STL file and, if possible, prepare it for slicing with PrusaSlicer or OrcaSlicer. Write a brief design journal explaining each step and the programming logic used.

3D design BlocksCAD 3D printing Medium
07

Circular economy audit

Choose 5 electronic products you use regularly (phone, laptop, headphones, game console, tablet). For each, research:
(a) Planned obsolescence indicators (how long until it's unsupported/breaks?).
(b) Repairability score (check ifixit.com).
(c) Which of the 9 R's applies when it reaches end-of-life.
Present your findings in a Google Slides deck (1 slide per product). Conclude with a class-wide sustainability ranking and three actionable recommendations.

Sustainability Circular economy Research Medium
6.0

Self-assessment Quiz — Unit 6

📝
Instructions

12 questions covering all sections of Unit 6. Select your answer — immediate feedback is given. Check your total score at the bottom. Each question has only one correct answer.

Q01 / What is the correct order of the programming process?
A
Programme → Analyse → Define → Check
B
Define → Analyse → Programme → Check & debug
C
Analyse → Define → Check → Programme
D
Check → Programme → Define → Analyse
Q02 / In a flowchart, which shape represents a decision?
A
Rectangle
B
Oval
C
Diamond
D
Parallelogram
Q03 / In Scratch, what is a "Sprite"?
A
The background image of the stage
B
An object or character on the stage that has its own routines
C
A block that repeats instructions
D
The programming window in Scratch
Q04 / Which Scratch block category would you use to make a program repeat instructions until a condition is met?
A
Motion
B
Operators
C
Control
D
Variables
Q05 / App Inventor is used to create apps for which operating system?
A
iOS
B
Android
C
Windows
D
Linux
Q06 / In App Inventor, you need to store 10 quiz questions. The best data structure is:
A
A single variable
B
A Canvas component
C
A list (ordered collection)
D
A label component
Q07 / What does "debugging" mean in programming?
A
Writing the first version of the code
B
Designing the flowchart
C
Finding and correcting errors in the program
D
Translating code into machine language automatically
Q08 / In a machine learning project, what is the purpose of "training data"?
A
To speed up the computer's processor
B
To give the AI labelled examples so it can learn to recognise patterns
C
To store the final version of the program
D
To connect the app to the internet
Q09 / BlocksCAD is primarily used for:
A
Writing Python code
B
Designing mobile app interfaces
C
Creating 3D objects using block-based programming
D
Simulating pandemic spread
Q10 / "Planned obsolescence" refers to:
A
A method to make software run faster
B
Designing products to fail or become outdated quickly, driving over-consumption
C
A type of AI that plans future schedules
D
A circular economy recycling method
Q11 / In the pandemic simulation, what Scratch feature was used to create multiple copies of the cat sprite?
A
Duplicate costume
B
Create clone of…
C
Broadcast message
D
Make a list
Q12 / Which of these is the correct priority order in the circular economy?
A
Recycle → Reuse → Reduce → Refuse
B
Recycle → Repair → Reduce → Refuse
C
Refuse → Reduce → Reuse → Repair → … → Recycle
D
Reduce → Recycle → Reuse → Repair