HACKER Q&A
📣 fdeage

Interesting Python mistakes for teaching CS to high schoolers?


Hi,

I am a CS teacher in France, currently teaching Python to 16 yo as their first programming language.

There are millions of good tutorials online to learn Python. However, while these can teach rules and principles to follow (the stuff you should do), I'm looking specifically for a list of mistakes (the stuff you shouldn't do), why beginners tend to make them, and what you should do instead (like comprehensions instead of iterations, etc.)

I find learning from mistakes to be incredibly more efficient sometimes than just telling students what works.

Any suggestions?


  👤 necovek Accepted Answer ✓
Python is a great introductory programming language, but ill-suited to get people to understand computer science underpinnings, mainly because there's such a discrepancy in performance of C-based Python structures compared to pure Python (eg. list.append vs list.insert in large lists, string copying on change, list/set/dict comprehensions vs for-looping which you hint at).

I know at that age I was already getting acquainted with the big-O notation and such, and C-pointer arithmetic was already second nature, but it sounds like you are looking for something not-really-CS: so it'd be best if you elaborate on what are you actually teaching a 16 yo student, or what goals does that 16 yo student have?

If it's just about getting someone interested in building programs for themselves, I find the most important thing is to keep the motivation, which means finding a project they care about ("let's sort your gallery into folders"), and Python is an excellent choice for that.

But I wouldn't focus on specifics you mention, because they are so... well, specific to Python data structures and control flow. And then you can use NumPy structures to solve an entirely different set of problems.


👤 rgacote
A mistake I still occasionally make today is:

a = 123, # expecting a to be 123, not (123, )