Skip to main content

Computational thinking

Generalization

Find the pattern shared by related problems and turn it into one rule, model or solution you can use again.

Try the example
Three orange rectangular frames with different dimensions. Each has two pairs of equal sides.

One rule for any rectangle

How can you find the distance around a frame when its length and width keep changing?

Step 1 / 3

Add the four sides

The sides measure 4 and 2 cm. Follow the outline and you get 4 + 2 + 4 + 2 = 12 cm.

How to make a solution reusable

  1. Spot the shared structure

    Compare a few solved cases. Every rectangle contributes two lengths and two widths, whatever the measurements.

  2. Give the changing parts names

    Replace the particular numbers with l and w. These parameters can take new values while the calculation stays the same.

  3. Test a new case and its limits

    Try a different rectangle, including a square. An arbitrary quadrilateral may have unequal opposite sides, so this formula does not cover every four-sided shape.

One solution, several uses

A greeting for any name

Ani, Davit and Nare can all use the same greeting function. Pass the name as an argument each time.

A packing checklist

After a few trips, make one list of the things you always need. Reuse it and add items for the weather or the length of the trip.

Python
def greet(name):
    print("Hello, " + name)

greet("Ani")
greet("Davit")
greet("Nare")

How the skills connect

Keeping just the stations and lines on a metro map is abstraction. Reusing one route-finding method across cities is generalization. To build that route planner, break the job into three parts. One reads the map, one finds a route and one displays the stops.