Technovation logo

1.5. Learning to Code

1.5.1. Why learn Coding?

What are some reasons to learn to code? (Click on the dark gray buttons below.)

Q-1: What are your reasons for wanting to learn to code?

1.5.2. Terminology

Listen to Mike’s rap about coding to learn his answers to:

  • What is code?

  • Where is code?

  • Who codes?

  • Why learn code?

Here’s some other terminology that you’ll want to become familiar with (click on the buttons to read our definitions):

Check your understanding.

The distinctions between these terms can be illustrated by analogy.

image of teens following a recipe (clipart-library.com/clipart/26)
clipart of dog pondering an equation involving bones (CoolCLIPS_vc016297)
image of a trainer trying to get a dog to jump through a hoop (Cliparts.zone/clipart/675010)

1.5.3. Python Turtle Graphics

You’ll be learning coding using Python Turtle Graphics, a library of code that is written in the Python Programming Language.

To whet your appetite, here’s an example program in a Runestone active code widget.

Don’t worry about understanding this code just yet. But notice what it looks like — the code has odd-looking words, punctuation, numbers, and math-like symbols. They all mean something to the computer. So does the indentation. We’ll learn the rules for writing code like this in the weeks ahead.

The white area in the active code widget is an editor. You can scroll through the code if you place your cursor into editor. You can change the size of the editor by dragging the bottom-left corner up and down. You can also modify the code. But don’t do that just yet!

For now, just scroll the contents in the window and resize the editor so the Run button is at the top of the window and you can see a good four inches or more below the editor. (To scroll the window contents, place your cursor outside the editor.)

Then click the Run button to see what running the code produces. After pressing Run, you need to scroll down below the code editor to see what the program draws.

To get practice running code and see what you can learn by doing so, perform the following experiments.

Experiment #1

  • Scroll down in the editor (white area containing the program) to line 39. Then change the 3 in this line to 4.

  • Run the code again.

  • Notice the differences between the what the first program draws and what the modified program draws. (Use the slider at the top of the active code editor to go back and forth between the two programs and re-run them as needed. This slider keeps a history of all the code you execute so you can always go back to an earlier version if you make a mistake or just want to remember what it looks like.)

Experiment #2

  • Change the 4 that you entered in line 39 to 2 and run the code another time.

  • Notice the differences between the three versions of the program. (Again, you can use the slider to go back and re-run any of the versions that you’d like.)

Q-6: Based on these experiments, what do you think the computer uses the number in line 39 for?

Experiment #3

  • If the number in line 39 isn’t still 2, change it to be 2

  • In line 37, change the 0 to -100. (This will make the instruction be p2 = [-100,100].)

  • Run the program again.

  • Notice how this modification changes what the program draws.

Experiment #4

  • In line 37, change the -100 to 150. (This will make the instruction be p2 = [150,100].)

  • Run the program again.

  • Notice how this modification changes what the program draws.

Q-7: Based on these experiments, what do you think the computer uses the pair of numbers in line 37 for? (Suggestion: Use the slider above the editor and re-run the earlier versions of the code to remind yourself what each version does.)

Other Experiment suggestions:

  • Experiment with changing the pairs of numbers in lines 36 and 38.

  • Experiment with changing the names of the colors in lines 18 and 19.

Q-8: What did you learn from your additional experiments?

Isn’t it amazing how much you can learn about code just by playing around with it?

By the end of club, you will be able to design and code diagrams like this yourself! clipart of a smiley face with hearts for eyes

You have attempted of activities on this page