TransWikia.com

Any good resource for introducing kids to programming using Python's Turtle Graphics?

Computer Science Educators Asked by Kam Eissawy on June 1, 2021

I would like to start volunteering with kids and young teengers in my community by introducing them to programming. I thought teaching them the basics of python would be a good start. I have some experience with teaching in general (but not with teaching kids about programming).

Are there any resources that could help me or at least inspire me to make a good curriculum that goes over many concepts with turtle?

Thank you!

7 Answers

I have found that Python is not the best tool for teaching elementary and middle school students an intro to programming. Turtle is nice, but you run out of things to do pretty quickly. If you move on from Turtle to console based coding, many students find it less engaging.

Scratch and similar visual languages are much more engaging for younger learners. You will be surprised how full featured they are. There is a lot of great algorithmic teaching that you can do with these.

If you really want a traditional text-based language, you might check out Greenfoot (for Java). But again, younger learners get lost in the symbols pretty quickly, so it would not be my first recommendation. Scratch can be much more intuitive for them.

Correct answer by Bryan R on June 1, 2021

I concur with Bryan R that Turtle might not be a great choice for an in-depth introduction. A quick google search for "python turtle lesson plans" reveals that most plans are for one to three lessons, after which, you have pretty much exhausted what Turtle has to offer.

There are various paid resources for Python Turtle at teacherspayteachers.

If you are open to a slightly different, more graphical, version of Turtle (called "Tina"), there is a whole book of lesson plans available at nclab.

Answered by Ben I. on June 1, 2021

If these kids are true beginners Python is a bit much. Try Scratch or Alice. If you really want a line-code language go for Small Basic. All of these have excellent resources available on their website. Thunkable and App Inventor can also be a good start if you want to try something different.

Answered by Garth Flint on June 1, 2021

I disagree with other commenters who say Turtle is not the best intro to programming. I've explained a planned curriculum in another answer, https://cseducators.stackexchange.com/a/6651/9632

The great thing about turtle is that it can be used to teach modularity through procedures. Teach to extract the repeating pattern. Teach to name things (and yes, sensible naming of things is a problem for beginners). Teach typing familiarity with full names turtle.forward(50), rather some simplified. Teach procedure parameters and how they pass through functions. Teach procedure as an argument to procedure. Teach Descartes coords and coords manipulation. Teach events.

Each of these is hard topic, and turtle can provide lots of visual feedback to simplify understanding. Parametric graphics/animation is a good start.

Answered by danbst on June 1, 2021

I think I've recommended code.org before, but here I am recommending it again! I particularly like tools like AppLab (Link to the homepage of Code.org's AppLab) that allows students to flip between block-based and text-based (JavaScript) programming.

If you're interested in diving into hardware with them (which I would recommend because kids love to make stuff they can play with) Makecode (Link to MakeCode turtle projects page) allows you to flip between blocks and Javascript or Python. You don't have to buy the hardware to get started because there's a simulator. Makecode Arcade (Link to homepage of MakeCode Arcade) also let's you flip languages to build games.

Answered by Randi W on June 1, 2021

LibreLogo, available as default plugin of Writer LibreOffice is a good choice. I teach it to primary teacher students but I also made labs with 7-10 years old kids. Unfortunately, the manual I wrote is in Italian (Piccolo manuale di LibreLogo - Creative Commons License 2.5) but the coding examples are in English Logo. This text was written with the Bruner spiral curriculum in mind, i.e. you can find examples suited for primary school as well as secondary school students. I'm writing an English version (Building knowledge with turtle geometry) where I'm using both LibreLogo and Python. Will distribute it in the same way as soon as ready.

Answered by Andreas on June 1, 2021

Start with Scratch!

Scratch has all of the turtle concepts in it natively (they call the turtles sprites, and you can use the pen extension to draw), plus a ton of advantages that are critical for beginner programmers (especially young folks, but not exclusively; Harvard uses Scratch for introducing coding in CS50):

  • No typing skills are required (less of a problem for older learners, but can be a major blocker for youngsters -- I've taught Scratch to classes of 1st and 2nd graders and that's virtually impossible with Python).

  • No syntax frustrations because the blocks are all there in front of you.

  • It's largely self-documenting; the blocks are all there in front of you.

  • Having all the blocks right there means you learn more by hands-on experiementation in Scratch; Python turtle shifts the focus to reading documentation and tutorials, switching between tabs or consulting books and guides, activities that tend to only be accessible to older audiences.

  • Scratch's design eliminates many classes of silly bugs and lets students focus more on the payoff (fun) and on the high-level programming concepts without getting bogged down by the endless minutiae, gotchas and quirks that come with any powerful general-purpose language like Python.

  • Scratch runs in the browser (the place where beginners will likely be working) natively, unlike Python which is not a browser technology; no need for (often buggy/slow/poor UX/UI) third-party sites like trinket or repl.it or installing/setting up offline IDEs to make the development workflow tolerable.

  • Scratch has a great community of inspirational projects (this can be a downside; some classes I've taught Scratch in turn into a battle against kids playing griffpatch games all hour -- Snap or offline Scratch solves this problem, or using a browser extension or whitelist to keep them tied down to projects starting with their username...).

  • Scratch has built-in, incredibly easy-to-use sprite, sound and audio editors; computer vision motion detection; advanced collision detection between sprites and colors; integrations with hardware extensions; etc. These features would be prohibitive to implement with a beginner in Python.

  • Scratch makes asset management (images, sounds) effortless.

  • Scratch has great builtin assets so students can get to creating something visually impressive right away. With turtle, they'll generally be drawing simple shapes for starters.

  • Scratch is more effortlessly powerful than Python turtle in ways that are specific to the sort of projects beginners typically want to make (in addition to making turtle-oriented apps easier to make).

  • Scratch offers a gentle introduction to coordinates by showing the mouse and sprite positions when the program isn't running. In general, Scratch has anticipated pain points like this and has baked solutions into the UI in ways Python turtle hasn't (and can't).

  • Scratch isn't exactly object-oriented, yet it has separate scripts for each sprite (data is shared globally but usually doesn't play much of a role in a typical beginner-level Scratch program), so there's enough separation but without all the baggage of OOP.

    It's true that state management and event handling for clones can be a major pain but that's pretty advanced Scratch that will probably never be encountered except by the most dedicated students.

  • Control flow in Scratch largely just works. You can slap on a bunch of "forever" blocks and run the app without having to fuss with putting turtle.mainloop() in the proper location. Event handling, clicks and messages are generally very easy to deal with for basic and intermediate use-cases.

Furthermore, Python turtle has a ton of disadvantages (or "characteristics", to use a more measured word) that harm its usefulness for beginners:

  • To be able to use Python turtle, you have to use Python on a decent-enough level. Python is a full-featured programming language that isn't trivial to gain a basic command of in its own right.

    If the primary goal is to learn Python specifically, turtle isn't a bad way to do it, particularly for younger learners. But then again, most folks will probably learn Python without graphics because they're probably old enough to want to use it for something other than game design or animations.

    Scratch totally eliminates the distinction between the language and the graphical module (clearly, having decoupled modules is key to the usefulness of a general-purpose language like Python, but it's just a hindrance if you're only using it for turtle -- sort of like buying a whole car just to listen to the radio).

  • Variables and state are a bigger deal in Python, and it's really easy to get into ugly situations with global variables and functions and wind up with a mess. Yes, Scratch variables are global, but you can get pretty far without using them much at all.

  • By nature, you (sort of) have to teach a certain amount of OOP along with Python's brand of turtle, but then the turtle module itself breaks various rules of OOP in ways that are questionable and sources of confusion, like calling methods from the procedural interface along with the object-oriented interface.

  • The design of the turtle library from a software engineering perspective is a bit weird, involving various awkward ways of doing basic things, redundant and poorly-named methods (What does "pu" do? Does "down" move my turtle down? Oh wait, it puts the pen down...), questionable design choices and a lot of bloat (150+ methods just to achieve what Scratch does in a few dozen blocks -- yes, half of these methods are duplicates in defiance of the Zen).

  • Window/screen/event management in turtle can be a headache.

  • Control flow in Python turtle can quickly ruin the party -- it requires some understanding of timers, blocking calls, first-class functions (for event handlers) and so forth. It's not uncommon for a student to put a blocking call above other code and wind up wondering why the program hangs or forget to make a blocking call to run the animation loop. Misunderstandings like this get in the way less frequently in Scratch. It's not impossible to miss some extremely subtle detail that halts your app, just harder with Scratch.

  • Python turtle involves a lot of combing the docs to figure out what stuff does. And that's just the module, not to mention the rest of the language.

    Add to that the fact that Python 2 has many subtle differences from Python 3, so it's super easy to wind up looking at the wrong docs entirely.

    Sure, these skills are super-important for actual development, but there's no point foisting them on anyone until they're mentally ready for the challenge.

  • Python has limited options for further pursuit of graphics/interactive applications. Pygame is a typical next step after Python turtle, but it can be a leap in both power and complexity and runs into the same old environment issues where it's simply non-native for the browser, the de-facto beginner development environment. Once again, Scratch covers most of the features of Pygame a beginner would use and be able to appreciate.

    After turtle and Pygame (and maybe a text adventure project), the stuff Python is useful for (data science, AI/CV/NLP/ML, backend web apps, data mining, etc...) tends to be too complex and abstract for beginners of any age who prefer visualizations and interactivity. It's fine to switch between languages, though, so this isn't a complete deal-breaker, and Python certainly is used as a scripting language for most things eager students might want to investigate (say, robotics) and has a fantastic ecosystem of packages, so this is a somewhat minor point.

Ironically (because of the very non-beginner-level context), one of the most effective uses of Python's turtle I've seen was as a lightweight visualizer in the coursework for a graduate-level AI course on robotics.

Although this seems like a big rant against Python turtle (or even Python in general), I'm actually quite fond of turtle. It's a useful, simple, fun drawing package that's a great tool to have in Python. But I think it's overprescribed to many curricula or individual learners when Scratch would be far easier and more effective at achieving the goals of engagement and communicating the basics of programming for most audiences, particularly young ones.

I emphasize the quirks of Python turtle because, as experienced programmers and educators, it's easy to forget all of the countless frustrations that come with learning programming for the first time. The extent to which Scratch streamlines the development experience and lets users work at a high enough level that they can build cool stuff with a minimal amount of frustrations and gotchas is remarkable.

Students will have plenty of time to learn how to navigate docs, engineering patterns and language quirks once their appetite for coding has been whet and they're confident with basic control structures and logic.

Does Python/turtle offer anything to beginners?

Of course. Students who've spent at least a bit of time with Scratch and are eager to move on to Python specifically and have a decent reason for pursuing the language should be a fine fit for turtle. Turtle can be used for a handful of lessons to gently help translate concepts from Scratch into written code while introducing Python syntax and concepts like objects and methods.

Some students feel that Scratch is a silly toy (understandable, given the colorful drag 'n drop interface and chipper, wholesome look, but incorrect) and want the feeling of something more "grown up", i.e. a written language. In many cases, I've found ambitious students sometimes get more than they've bargained for and wind up going back to Scratch, at least temporarily, upon tasting the difficulty of Python: syntax errors, typing the code out, having no idea what to type or where to find help, little concept for the syntax and semantics of a program, etc.

Students in typed languages are likely to require more hand-holding and guidance, and may develop less independence than block languages like Scratch.

Python with turtle might be a better fit than Scratch for math classes for older students because stacking tons of math blocks in Scratch can get nasty. Peter Farrell has a great book and blog called Hacking Math Class (but then again, he's using a ton of p5.js nowadays; more on this below) that seems like a potential opportunity for turtle over Scratch. This use-case is mostly single-turtle (meaning you can use the procedural interface) and non-sprite-oriented, with coding based mostly on simple movement commands and focus on math formulas.

That said, Python isn't necessarily my first choice to recommend as a beginner language, even after Scratch, because it's not as natively interactive as HTML5 (HTML, CSS and JavaScript). I think the benefits of Python for beginners are overrated, particularly for younger folk. Which brings me to my next point.

Consider HTML (and HTML5, p5.js)

It hasn't been mentioned yet in this thread, but HTML is a fantastic option to consider as an alternative to (or in addition to) a turtle-oriented curriculum. Yes, HTML is typed, isn't a genuine programming language, doesn't teach logic commands as turtle does and doesn't let you make games nearly as easily as Scratch (JavaScript required), but it has many benefits:

  • Instantaneous visual results with just a few lines of code.
  • Most everyone's used a webpage, so the motivation is obvious.
  • HTML is the most browser-native thing imaginable, so there are endless high-quality development environments that are robust and non-hacky.
  • You can have fun interacting with famous websites by changing text, background colors, images, etc, often to silly effect.
  • HTML is an extremely practical foundational lifelong skill even for people who don't consider themselves coders.
  • "Math-y" logic like loops and conditional statements are gone, so HTML can bring practical, creative computer skills to a different audience.
  • Web design scratches a different creative itch than Scratch, enabling students make a home on the internet and express their interests, values, personality, share images and ideas, link to other sites they like, and so forth.
  • With some assistance, it's not difficult to do quizzes and interactive fiction projects using text, links and images and introduce interactivity into projects incrementally.
  • HTML teaches tons of core CS concepts like trees/nesting/parent/child/ancestor, the idea of a node or element with state (input boxes) and properties, etc.
  • HTML is a forgiving language -- things can get messed up but even if the markup a student has written is pretty borked, you can get something on the screen and avoid intimidating errors. Linters and validators built into most IDEs these days will auto-close tags and show problems. The most typical problem is something not showing up because it's in the wrong spot or a missed closing tag.
  • HTML leads right into CSS and JavaScript, two outstanding domains for education. Adding style, buttons, alerts and forms to a basic HTML page can be tons of fun.
  • It's easy to add interactive videos and audio to pages.
  • CSS is extremely powerful and can do a lot with a little; cool animations can be added by copying and pasting from w3schools (yes, developers cringe, but just let beginners have fun making a mess!)
  • Ditto for JS: let students copy little trinkets and click handlers into their page that can flash alerts, change text and colors, etc.

With these basics in place, p5.js becomes a logical next step as an alternative to Pygame or Python turtle. JS is natively visual and p5 is easy to run; just navigate to p5's web editor or open a Codepen template. These environments are less brittle than the hacky Python graphics IDEs for browsers.

HTML, CSS and JS offers a rich variety of next-steps for pretty much any interest, even traditionally Python-oriented domains like data visualization, robotics and AI. p5 can do turtle-style graphics with an arguably better/more intuitive design than Python turtle (particularly the setup/draw loop).

p5's docs and examples are fantastic.

Going the JS route instead of Python as a next step after Scratch seems like a great fit for students who are visually-oriented and prefer interactivity to console-based programs and utilities (although NodeJS does that just fine, too).

Consider Code.org

As another post mentioned, code.org is also great! The benefit of code.org over Scratch is that Scratch is a relatively unstructured sandbox which can overwhelm some learners. Code.org offers short block programming puzzles with clear structure and goals, teaching control flow, state and basic logic.

Among many other small apps and sites, there's a code.org-like Google Doodle that I've gotten good mileage out of with coding novices of all ages and might make a fantastic day-one start to a curriculum.

Honorable mentions

I don't have much experience with these, but Racket (for older students -- it does turtle graphics nicely, but the language is a Lisp) and something like Lego Mindstorms, a block language for robotics, deserve mention (controlling a robot in Mindstorms is the same as controlling an on-screen turtle).

Answered by ggorlen on June 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP