Skip to content

5 min read

American Corners

From basics to structures

What you are expected to bring

This course does not start from zero. It assumes you have already met the building blocks of Python and can use them without looking them up every time. You know how to store a value in a variable, how to make a decision with if and else, and how to repeat work with a for or while loop. You can wrap a piece of logic in a function and call it with different inputs.

You have also met the list, the first place most people put more than one value at a time. If a line like the one below reads naturally to you, you are ready:

grades = [92, 74, 88, 100, 63]
total = 0
for grade in grades:
    total = total + grade
print("Average:", total / len(grades))

We will not re-teach any of that. If it feels shaky, the Python course is the right place to steady it first.

What this course adds

From here the focus shifts from single values to the shape of your data. A list is only one way to hold a group of items, and it is not always the best one. Over the coming lessons you will pick up several more:

  • Collections beyond the list: tuples, dictionaries and sets, each with its own strengths.
  • Files, so your data can outlive a single run of the program.
  • Data structures such as stacks and queues, which are less about storage and more about the order in which items come back out.
  • Algorithms, the step-by-step recipes that work on those structures, and a way to compare how well they scale.
  • Object-oriented design, where you bundle data and the actions on it into your own types, and later ideas that build on the web.

Why the shape matters

Two programs can produce the exact same answer while doing wildly different amounts of work, and the difference often comes down to which structure holds the data. Choosing the right one can turn a program that crawls into one that flies, without changing what it computes.

Tip

As you read on, keep asking one question of every new tool: what does it make easy, and what does it make hard? That single habit is what separates picking a data structure on purpose from picking one by accident.

You already have the vocabulary of programming. This course is about using it with more judgement, so treat what follows as new words in a language you can already speak.

Try this now

Write a short program from memory that averages a list of numbers. If any line feels shaky, revisit that topic in the Python course before you go on.

Check yourself

  1. This course assumes you are comfortable with four basic building blocks of Python before you begin. Name them and give a one-line reminder of what each is for.
  2. In your own words, what is the difference between the storage a list gives you and the order that a structure like a stack or a queue is really about?
  3. Why can two programs that always return the same answer still be very different in practice? Point to the idea from this lesson that explains it.

Where this lesson comes from

Built from

  • Data Structures and Algorithms

alphaPlan courses are built from taught programmes rather than invented for the web. Where a claim rests on an outside standard or a reported case, it is named above so you can check it rather than take our word for it.

This course was developed by alphaPlan Center from programs delivered in partnership with the American Corners network.

Found something unclear, outdated or improvable? Suggest an improvement