Tag Archives: coding with Python

Techniques to Teach Debugging Strategies

When designing a Python programming unit, include lessons with techniques to teach debugging strategies. Debugging is the ability to find and fix errors in code. It is a vital skill for young programmers to master.

Don’t hope that students will discover these strategies on their own. Instead, guide them through proven methods.

Explicit Strategy Instruction and Debugging Strategies

STEM classes emphasize writing code to animate objects, create artwork, or build games. In the push to build a program, the ability to edit the code may not be a focus of instruction. In this learning environment, identifying mistakes and correcting them becomes an implicit process.

During programming lessons, students need to decipher the meaning of error codes independently. They must spontaneously determine how to solve the problem. The young programmer can be left feeling inadequate as they struggle to get their programs to run.

Frustration is an integral part of the learning process. It fosters persistence, which is an admirable quality in a programmer. However, for many beginners, the challenges can seem insurmountable and they give up – telling themselves, “I am not good at programming”.

There is a better way!

Explicitly teaching debugging strategies empowers learners. No longer will they feel defeat when an error message appears. Instead, they have techniques to competently debug the Python program. This builds confidence and promotes a positive attitude towards STEM.

4 Techniques to Teach Debugging Strategies

1. Break It, Repair It

There are many techniques to teach debugging strategies. One that is very effective is to intentionally break code, then run the program to notice the result. This type of STEM lesson takes very little instructional time, yet quickly improves debugging skills.

To start, provide students with a Python file. Using direct instruction, have them systematically delete parts of the code to generate common errors. When the program is run, the instant feedback forms a connection between bugs, error messages, and how to fix the problem.

Some suggestions for breaking the code include:

  • remove vital lines such as the import of a library to note how commands are no longer recognized
  • add or delete punctuation such as quotes, brackets, colons, and commas to explore their purpose
  • adjust the indent level of a block of instructions to see how it influences the program
  • alter symbols such as ==, !=, <, and > then study how they alter the output
  • misspell a command to highlight the importance of accuracy when typing code
  • turn an equal sign == into = to notice how the code no longer works

Using these techniques to teach debugging strategies will enhance your students’ programming skills. If you are looking for a ready-made Python lesson, TechnoTurtle has a Bug Zapper exercise. Students follow instructions to produce bugs and then repair the code. This activity is ideal for beginners in Grades 3-9.

break the code

Intentionally break the code. This provides instant feedback when the program runs forming a connection between bugs, error messages, and how to fix the problem.

2. Code and Correct

Another debugging lesson is one that guides students through the development of a program. Using direct instruction, the teacher outlines the goal of the programming task. Line by line, the teacher types the code that the students copy. After each line, students run the program to study the output. When a mistake occurs, the teacher highlights the issue and explains how to troubleshoot the code. Slowly, the program takes shape.

This technique best suits students that are familiar with syntax and name errors. Instead of focusing on typos, this lesson emphasizes the quality of the output. It studies the outcome and provides solutions on how to improve the code. The sample program should be short. It must have common pitfalls to resolve as a class.

TechnoTurtle, a Python programming project for beginners, has several lessons that are ideal for a Code and Correct lesson. For example, students follow steps to draw a robot. Throughout the learning process, problems are intentionally generated. This provides an opportunity for beginners to think about the code and how to improve the program’s design.

techniques to teach debugging strategies

  TechnoTurtle includes techniques to teach debugging strategies. Follow the guided instructions to fix the code.

3. Explore and Investigate

Invite exploration into your STEM lessons to promote a positive attitude towards debugging. Often troubleshooting a program’s output can be a source of frustration. However, in this activity it is fun. Encourage students to play with different values to notice how they change the outcome. Investigate by making a number higher or lower. Or, replace a string with another option.

Explore and Investigate is meaningful. Active discovery demonstrates why one value is better suited to the program than another. It transforms mistakes into happy surprises.

Sparking a life-long interest in STEM is one of the goals of programming lessons. In TechnoTurtle, there are many activities in which students modify the values within a program to achieve a unique outcome. This makes learning enjoyable, which hopefully promotes an on-going interest in programming.

explore and investigate

Invite exploration into your STEM lessons to promote a positive attitude towards debugging.

4. Pick the Correct Code

Another technique to improve debugging skills is to provide students with snippets. Rather than mindlessly copying code they are presented with two options. One snippet is correct, the other has a bug. By making choices, the young programmers write the program.

This type of programming lesson actively engages students. They must study the code and think about the choice they will make. If they are incorrect, the feedback is instant. They can then use the other option instead. This activity cultivates a learning environment where it is safe to make mistakes.

An example of a similar programming activity is Clean Up the Code in TechnoTurtle. Young programmers determine how to debug the code. The program they are editing should stamp turtles on the canvas. However, it has four errors. For each error, they are given two choices. This activity builds debugging skills.

safe to make mistakes

Cultivate a learning environment where it is safe to make mistakes.

Apply Multiple Techniques to Teach Debugging Strategies

When teaching your next programming unit, design lessons that explicitly teach debugging strategies. This will build competence in your students and support independent learning. As well, this instructional approach has the potential to transform how students feel about errors. Turn your STEM classroom into a safe place to make mistakes.

Design a Coding Unit for the Classroom

STEM learning objectives are being included in many school, district, and national curriculum standards. As a result, educators are challenged with creating engaging and challenging instructional materials to teach computer science skills. But most teachers don’t have a technology background, much less knowledge of programming. Here’s some help. Whether you’re using ScratchJr, Scratch, HTML and CSS, or Python and the Turtle Library, the activities will be similar. Following are some basic strategies to consider when you start to design a coding unit for the classroom.

Practice Sequencing Algorithms Offline

Design a coding unit to include offline exercises. This will develop computational thinking. A starting point for instruction is to build algorithms. An algortithm is a description of the program. It uses words and symbols to sequence the instructions.

The logical order of coded instructions is critical. To build this skill, instruct students to physically act out and order a list of directions in simple, everyday language first. For example, if a programmer had to write a program for the task of putting a piece of paper into the trash, it may have the steps:

design a coding unit

Have students act out the steps they listed to check them. Or, have a list of mixed up steps that students must unscramble to place them in the correct order.

Start Simple

When you design a coding unit, move from simple to more complex code slowly.

Don’t offer a complete set of instructions in code and have the students copy it and run it to see the result. This may intimidate young programmers and even make them think that coding is too difficult. Moreover, they won’t learn what each part of the code does.

Instead, write a few lines. Then test the result. The instant response will create a connection between the coding and its function.

coding for kids

In TechnoWhiz, primary students are introduced to ScratchJr by using one block at a time to move the character on the stage. They observe the resulting motion. Then they combine a series of blocks to create a script and see the effect. Next, they add more characters and move them, and learn to loop their actions. By the end of the project, they are able to make an interactive, one-of-a-kind racing game with a background, formatted text, and characters moving at different speeds, dancing, and talking!

Use Trial and Error

Invite students to experiment with values to figure out what works. Try a number or value. Does it need to be higher or lower? Test often to see what works.

Encourage exploration. For example, when using Python and the Turtle Library, circle(50) draws a circle with a specific size. Students can explore by changing the number to a higher value and a lower one. Or code left(90) to turn the turtle symbol. Then change the value to see what angles the turtle turns. The repeated experimentation will result in learning that can be applied in subsequent activities.

Teach Debugging

Don’t wait until mistakes are made. Early in the project, create errors with intention. Have students ‘break‘ the script, then fix it. As a result, they will recognize mistakes that may be made later in their own programming and be more likely to correct them independently.

design a coding unit

Apply Skills

Introduce a skill, repeat or review it, and then transfer it to another application using the program. Avoid teaching a concept in isolation. When students re-use skills in different contexts, they will accumulate their knowledge and be able to apply it in their own creative projects.

teaching coding to kids

For example, in TechnoTurtle students learn to use Python to control the movement of a turtle symbol. Then they apply their skills to write scripts to draw pictures and to move the turtle through a maze. In other parts of the project, they learn about variables. Then they use this concept to create Mad Libs and to produce an interactive carnival game.

Show Samples

Demonstrate how a completed project might look at the beginning of a lesson. This will serve multiple purposes: students will have a clear idea of what they’re making, they will be inspired to create their own unique version, and the sample can be a coding reference guide to use if trouble shooting is needed.

In TechnoHTML, a sample web page about skateboarding sparks student interest and demonstrates the skills they will learn using HTML and CSS:

design a coding unit

  • Formatting text
  • Adding images
  • Making lists
  • Linking to sites

Provide an Opportunity to Share

At the completion of the project, ensure that students have an authentic audience. This helps students to connect their work in the classroom to the real world and see a purpose for their efforts. Their peers are a perfect audience. Celebrate the finished projects and encourage interaction and feedback. The digital nature of programming projects makes it easier than ever to share work with classmates, family, and friends.

design a coding unit

For example, in TechnoCode, middle school students place their collection of completed animated scenes, stories, mazes, and games into an Activity Studio to share with others.

Then they invite feedback and recommendations for improvements.

Reflect on Learning

Finally, give students an opportunity to reflect on their experiences in learning to code. In either written form in a journal or as a class discussion, ask:

  1. What did you like about learning to program?
  2. Is there anything in your project that you would like to change?
  3. What do you wish you knew how to do?
  4. Have you learned anything about yourself?
  5. What advice would you give to a beginner programmer?

design a coding unit

In TechnoTales, students in grades 2 to 5 use five simple reflection responses to gain some insight into their learning.

The young programmers used Scratch to design a story with four scenes, multiple animated characters, a plot with a dilemma to solve, and a happy ending!

Design a Coding Unit

TechnoKids has elementary and middle school programming projects for Scratch Jr, Scratch, Python and the Turtle Library, and HTML. Before starting to design a coding unit of your own, try one! Visit the TechnoKids online store.

design a coding unit

TechnoKids has programming projects to teach ScratchJr, Scratch, Python, and HTML and CSS

Tips for Teaching Coding to Kids

Teaching coding to kids is more than just giving them lines of code to copy and then run. We want to empower students to become critical thinkers and innovative programmers. To build programming skills, beginners need to be provided with a variety of analytical and engaging experiences. To do that, we should spark their enthusiasm with a collection of activities that ensure success and an understanding of essential coding concepts. As they learn how to code original creations, students will become keen, competent programmers. They will have the foundational STEM skills for the workplace of the future.

tips for teaching coding

Here are some suggested types of activities to consider when teaching coding to kids.

Explore and Investigate

Teach code a line at a time. Then ask students to analyze and experiment with the code. Explore with different values and see the outcome. What happens with a higher or lower number? When the line of code is moved to a different place, what happens? What happens when a character is omitted? This strategy builds student insight into the meaning of the code so much better than just asking them to copy a given set of instructions and then running them.

Guess and Check

Provide completed code and ask your students to be detectives. By reading the lines of code, comments, or scanning for words they recognize, they can try to infer what the code will do. Then run the code and see if their guesses were accurate. This makes students keen observers and critical thinkers.

Use Templates to Jump Start Learning

Young programmers have the ability to understand the code, but don’t always have the keyboarding skills needed to type many lines of code accurately. When introducing specific coding concepts, consider giving the students templates with parts of the code already written. The students just add code to make the desired result.

Teach Debugging Early

Don’t wait until errors occur and students are frustrated with the inability to correct them. Near the beginning of the coding unit, have the students generate specific errors to break the code. Have them see the resulting problem. Then fix it. As a result, students will become familiar with common mistakes such as omitting characters, mistyping, or placing code in the wrong order. They will recognize errors and know how to correct them.

Provide Samples to Spark Inspiration

Before starting a new project, inspire students by showing them a completed sampler. The goal is to ignite their interest but not to provide a set of instructions for them to copy. The code becomes a guide for students. They can use it as a starting point or to compare their work for troubleshooting. The sampler becomes the foundation for students to produce their own original projects.

Offer Support References

Online programming reference lists and libraries are usually so complete and exhaustive that they are ominous for kids to use. Instead, build a list of basic commands that will be used in the project and have it handy for the class to use and check.

Present Opportunities for Extra Challenges

Differentiated learning studies have shown us that students build skills in a highly diverse way. When teaching coding to kids, they are certain to progress at different rates. Students who struggle need support, repetition, and review activities to grasp coding skills. Some students will ‘get’ the concepts quickly and be ready for new ways to apply and extend their learning. Be prepared for these young experts with optional challenges to keep them excited and involved.

Reflect on Learning

During, and definitely after the end of the project, provide an opportunity for students to think about their coding experience. Write a journal entry. Ask questions such as: What was your favorite part of the program? What was the hardest part of learning to program? Which skills would you like to learn next? What advice would you give to a person learning how to use this program?

Teaching Coding to Kids Using TechnoTurtle

teaching coding to kids

TechnoTurtle, a new project by TechnoKids Inc., is an introduction to Python coding for beginners. It is designed for elementary and middle school students to learn basic programming skills. The fun activities include building a maze, creating artwork and spirographs, and inventing interactive games. TechnoTurtle incorporates all the above strategies to inspire young programmers to acquire fundamental technology expertise.