Tag Archives: coding

Teach Debugging to Beginners to Build Confidence

It is important to teach debugging to beginners right away. Debugging is when a programmer finds “bugs” or errors in their code and fixes them to improve the program. This is an essential programming skill. So much so, that it should be taught at the beginning of a coding unit.

Where Were the Debugging Strategies in the Instructional Materials and Python Courses?

When I was asked to develop Python materials for TechnoKids Inc. I jumped at the chance. I began to read books about Python. They had titles emphasizing that the instructions inside were for “absolute beginners”. I noticed that none had activities or advice on debugging. Instead, if the code I was copying from the page didn’t work I was left guessing why. It was frustrating!

My reaction was one that I knew students would feel. I worried that young programmers might begin to think “I am not good at programming” when they encountered an error they could not fix. This belief might turn them away from learning more about coding. I knew it was necessary to reframe how students respond to mistakes in their programs. They needed to feel empowered, not defeated.

The books were helpful in understanding the types of instructional materials available to teachers on teaching Python – but I needed to learn more!

I wanted to understand the difference between what young children and young adults were learning about Python. I signed up for a first year course at the university where I did my undergraduate degree. This course did have a section on debugging, but it was at the end of the course. I asked the professor why it was introduced so late and was told it was because beginners could not understand the error messages until they had learned how to code. As a result, I spent a good portion of the course inefficiently applying debugging strategies. I knew there had to be a better way!

When it came time to create the TechnoKids Python STEM projects I had reached a decision…debugging needed to be taught right away. I wanted students to be able to understand the meaning of the errors they would see. More importantly, I knew they needed simple strategies to fix their code.

teach debugging to beginners

Teach debugging to beginners.

What Happens When the Program Keeps Shouting ‘You Are Wrong’…But You Don’t Know How to Make it Right?

When Students Lack Debugging Strategies, Red X’s Tell the Learner They Can’t Code

During my investigation of Python programming with kids I noticed that there were common errors made. These mistakes would trigger several responses by the IDLE Python program. The Python Editor Window, which is where programmers build the code, will display a box with a red x on Windows devices. Those are for syntax or indent errors. In this case, there might be a forgotten bracket or # in front of a comment: simple to fix, but not without knowledge of debugging.

The angry red x’s that show up on the screen mock a novice. Unintentionally they seem to say “you can’t code”. To prevent students from becoming discouraged, teachers should provide strategies for decoding error messages. This will build confidence and promote independence.

syntax and indent error boxes in Python

When a student lacks debugging strategies the Python error messages can be a source of frustration.

When Students Lack Debugging Strategies, They Can’t Find the Problem

Another technique the IDLE Python program uses to assist programmers is to identify a spot within the code where there is an issue. This is accomplished with a reddish-pink box around text. The skilled programmer knows to look BEFORE the highlight.

However, those without debugging strategies can stare at the code forever and never know what is wrong. This is because children and young adults are literal. They look at the reddish-pink text and say “Oh, the problem is right HERE”. Beginners lack sufficient knowledge to locate the error. This shortcoming can easily be overcome by explicitly teaching debugging strategies.

Python error

The word highlighted is not the error. It is the missing bracket BEFORE shape.

When Students Lack Debugging Strategies, Red Text Tells a Beginner They Do Not Understand How to Program

The error response by the IDLE Python program is to show a message in the Python Shell. The text is red. It often tells the programmer there is a name or type error. These errors can occur if a library is not imported, a command is spelled wrong, a variable is not used properly in the code, or a sentence does not use the correct punctuation for joining text with variables. The Python message identifies the line number and reason for the problem. However, with no debugging strategies it can seem like gibberish.

The red text in the Python Shell is the equivalent of using a red pen to grade student work. Many educators have given up this practice as it promotes self-esteem issues, which can turn students away from wanting to learn. Studies have show that for many learners red pen is like ALL CAPS. It yells “You are wrong!” When red text is the method for highlighting errors, it can make a student feel angry or sad. This is avoidable when educators teach debugging to beginners at the start of a coding unit.

Python error messages can seem like gibberish to beginners.

Teach Debugging to Beginners at the Start of a Coding Unit

To avoid making students feel bad about themselves, why not just give students perfect code to copy? Then when they run the program, no errors will happen. Or if they do, they can quickly refer to their sample to find the typo. Problem solved!

No. Not really.

The limitation to this instructional approach is that it restricts learning. One of the goals of teaching a STEM project should be to support students so they produce their own original creations. Aside from developing programming skills, the learning objectives in a programming unit should include: fostering an interest in programming, developing computational thinking skills, and applying logic and reasoning to solve a problem. The aim should not be improving typing skills.

Spark an ongoing interest in programming. Teach debugging strategies at the beginning of a coding unit. This will build confidence and promote independence.

Python Lessons that Explicitly Teach Debugging to Beginners

Teachers need to deliberately teach debugging strategies at the start of a programming unit. This empowers students. Using this instructional approach, the TechnoTurtle STEM project includes activities that teach students about common errors and how to fix the code.

TechnoTurtle has 30 coding assignments. Elementary and middle students solve mazes, create artwork, and build games. Several of the lessons emphasize debugging strategies. They are interwoven throughout the project to introduce or reinforce computer science concepts:

  • Edit a Python Program: Modify values to understand the purpose of code.
  • Bug Zapper: Add mistakes to a program to learn how to debug Python.
  • Clean Up the Code: Fix coding errors by selecting from the list of choices.
  • Trial and Error: Test different ideas to move a Turtle through a maze.
  • Draw a Robot: Write one line of code at a time and make corrections as you go.
  • Edit an Invitation: Change code to discover how to join text with variables.

Beginners Coding Guide Online Resource for Educators

Attention teachers and home school parents, AT&T has just released an online Beginners Coding Guide. It is a free interactive learning resource to introduce basics of coding. By reading information and answering questions students gain valuable programming knowledge. Upon completion, they earn a certificate to celebrate their accomplishment.

This online resource contains four modules about Programming, Data and Variables, Control Structures, and Sorting. Each module is divided into short assignments. An assignment begins with text that students must read to learn about programming. Afterwards, they answer multiple-choice questions to demonstrate their knowledge.  

Students control the pace of learning. By clicking the Next button, they move from one section to the next. At the end of each module is a Lesson Recap.

Tips to Use the Beginners Coding Guide in Your Curriculum

Set Aside a Block of Instructional Time: The modules must be completed in one class. Students cannot bookmark their place and return to it later.  For this reason, allocate about one hour for completion.

Guide Students Through Resource: If instructional time is limited or students struggle with their reading skills you may want to act as a course tour guide. Read the information together as a class, and then have each student on their device select an answer to a quiz question. This will allow everyone to progress through the modules before the class period ends.

Monitor Quiz Taking: To foster a love of learning, if students select the wrong answer during a Beginners Coding Guide quiz they can try again. This is a great way to empower students and keep them motivated. However, there is the possibility that students could skip the readings and then mindlessly pick a, then b, then c; until the correct answer reveals itself. Theoretically, your students could earn a certificate without reading the content or critically thinking about their answers. To promote learning, actively monitor students to verify they are using the resource as an opportunity to learn in a fun way.

Coding Resources

Do you want your students to create coding projects? TechnoKids has instructional units, called technology projects, that include a teacher guide, workbook, and resources. You will have everything you need to teach programming including step-by-step lessons, sample programs, templates, coding journals, and quizzes.

  • TechnoWhiz: Code animations and games using Scratch Jr. TechnoWhiz includes fun coding lessons for primary students. Introduce students in Grades 1-3 to programming concepts.
  • TechnoTales: Produce an animated story using coding blocks in Scratch Jr. TechnoTales has easy to follow programming lessons for elementary students. Combine storytelling with coding.
  • TechnoTurtle: Solve a maze, design a spirograph, or code a Carnival game using Python and the Turtle Library. Activities in TechnoTurtle are ideal for students in Grades 4 and up.
  • TechnoCode: Code animated scenes and games using Scratch. Reflect upon the experience using coding journals. Activities in TechnoCode are ideal for students in Grades 6 and up.
  • TechnoHTML: Design a web page using HTML and CSS. Format text, images, and hyperlinks. Lessons are ideal for middle and high school students.

Python Variables and Offline Coding Exercise

Young programmers need to understand the purpose of Python variables. In a program, variables store values that can change. They are very powerful. They can be used to count, create lists, store user input, report information, personalize the user experience, trigger an action, calculate amounts, and more!

One of the best ways to learn about computer science concepts is hands-on learning. In other words, writing programs that use variables. Talking about variables will generate a limited understanding. Having said that, before jumping into Python programming, it is worthwhile to begin instruction about variables with an offline coding exercise.

Variables can seem a bit abstract to a child. It is worthwhile to make the concept tangible. A quick activity that connects variables to daily life will help elementary and middle school students to form an understanding of their use.

Have your students apply computational thinking to think about the world around them as a set of variables that store and direct events. This knowledge can then be transferred to programming activities. Refer to the connections below as a way to create an offline coding exercise about Python variables.

The Value of a Variable Changes

Just like the weather, a variable is a value that changes. It could be sunny in the morning and then rainy in the afternoon. What is the weather?

Complete the value of the variable weather. For example: weather="sunny"
weather="   "

A Variable Stores Different Types of Information

A variable can be text, a number, or a list. In the above example, the value stored was a word. However, you can also store numbers as variables. Temperature is a numbered variable that changes. It could be 5°C (41°F) at night and then 15°C (59°F) in the afternoon.

Write the value of the variable temperature. For example: temperature="15"
temperature="   "

The Value of a Variable Can Trigger an Event

The value of a variable can cause an action to occur. For example, if it is hot outside you might wear shorts. Or if it is rainy you might use an umbrella.

Complete the script using weather as the variable. What will you wear?

if weather=="snowy":
    what will you wear?

An Event Can Trigger the Value of a Variable to Change

When a program starts, a variable has a specific value. However, an event may occur that changes the value. This event could make a number higher or lower. Or, it could assign a new word to a text variable.

When making a decision you might change your mind depending on what is happening. Programs do the same thing! Pretend you are getting dressed for school. What piece of clothing do you want to wear?

Complete the value of the variable clothing
clothing="   "

The item is in the laundry. What piece of clothing will you wear now?
clothing="   "

A Variable Is Stored in a Numbered Location

The value of a variable is saved in a spot that is like a numbered storage bin. When the program needs the value in the variable it takes it from the bin. The computer knows where to find the value because it has a unique location.

Labeling a location to store things is done everyday at school. For example, your school locker may have a number. Or the library may have a numbered bin of books.

Look around your classroom. What bins are used to store things? Are they labelled?

Write your discovery as a variable. For example: mylocker="1215" or period1bin="homework"

bin="item"

A Variable Is an Efficient Way to Refer to Information

A variable is like a container that stores information. The label on the outside is the name. The item you put inside is the value. When giving an instruction, the program uses the variable name, not the data stored in it. This is done to save time and keep things simple.

Imagine it is recess time. The teacher needs to tell the students what to do. The teacher gives the instruction, “Please go and get your snack”. The teacher does not say, “Please go and get your apple, crackers, cookies, carrots, chips, or banana.”

The word “snack” is used to refer to many values. It also allows the values to be unknown. The teacher cannot know what you or your classmates brought for a snack. Using one word that is meaningful is an efficient way to refer to information.

People often use one word to quickly refer to many things. Turn the word lunch into a variable. What is in your lunch today? Make a list of the values in your lunch. For example:

lunch=("orange juice", "ham sandwich", "apple", "blueberry muffin")

lunch=

A Variable Can Store User Information

Sometimes the programmer assigns the value of a variable. Other times, the user inputs a value. This can be done by prompting the user to enter data by displaying a text box or question on the screen. The program can then use this information to sign into an account, customize the settings of an app, or pick a selection.

Think about a game you play on a device. What information does it ask you to input? Each of the pieces of information is a variable.

List two pieces of information you must enter into a game before you could play it. For example:

playername="technokid"

playermode="single player"

Python Variables and Fun Programming Activities for Kids

If you are looking for some fun programming activities for kids that use variables, take a look at TechnoTurtle. This STEM project introduces beginners to Python variables in a way that is easy to understand. Students develop programs that have players play Mad Libs, a Carnival Game, and a Guess the Number Game. Each uses variables to trigger action. These coding activities are a great way to make Python variables meaningful to kids. The lessons provide a foundation for further learning.

Python variables and TechnoTurtle

Teach children about Python variables using the STEM project TechnoTurtle.

Variables in Python and Teaching Coding to Kids

Variables in Python are used by programmers to store values. These values complete a task within a program. In game design variables can track scores, count the number of turns, or store player answers. However, they have many other uses. When teaching coding to kids, it is important that the purpose of a variable is understood.

variables in python

Variables in Python store values that a program uses to complete a task.

What Are Variables in Python?

A variable stores a value that can change. It is saved in a special spot that is like a numbered storage bin. When the program needs the value in the variable it takes it from the bin.

A variable can store lots of different types of information. For example, the value could be a number, text, or a list of items. In programming, a number is called an integer or int for short. Text is called a string or str for short.

A variable has two parts – name and value. To create a variable, you write the variable name, then an = symbol, followed by the variable value. For example: player=”Alex”

variable name and value

A variable has two parts – name and value.

Variables in Python Must Have Meaningful Names

Naming a variable is a fundamental skill. A programmer should be able to read the variable name and understand its use within the program. It is very important that it is short but concise. It’s name should describe its purpose.

A Python variable must:

  • be meaningful
  • be one word
  • have no spaces
  • use no symbols
  • not be a reserved Python word

Why Use a Variable?

Variables make a program flexible. Programmers use them for many reasons.

Variables Can Count the Number of Times an Event Occurs

Variables can count. This is useful when making a timer or tracking a player’s score. To count, you can create a variable called count=0. Each time the line of code count=count+1 is run than the value of the variable goes up by one.

Variables Can Store Multiple Values as a List

Variables can store more than one value. The list may look like this: pickcolor=(“red”, “blue”, “green”). By assigning multiple values to a variable it allows a program to make a choice. This use of variables creates games that are fun to play because the selection is unknown.

Variables Allow the User to Input Information

Sometimes the programmer assigns the value of a variable. Other times, the user inputs a value. This is done by prompting the user to enter data by displaying a text box or question on the screen. For example, the following code will store a user’s name:
name=input(“What is your name?”)

Variables Report Information

By using the variable name in a sentence you can report important information to the user. For instance, to display a player’s score the following code will join text with the variable value:
print(“The game is over. Your score is ” +str(score)).

Variables Personalize the User’s Experience

Variables can be used to communicate, making a device seem more human or less machine-like. Suppose that a player types in their name. Lines of code can have the computer give a personal greeting, such as Hello Sara. The sentence and variable are put together using this Python code: print(“Hello ” +str(player)).

Variables Can Trigger an Action

A variable’s value can change. If it is a number, it can get higher or lower. If it is a text, it could have another value assigned to it. Conditional logic can be used to trigger an action when a variable meets a specific condition. The value of the variable might need to be equal to, greater than, less than, or does not equal. When the variable value matches the condition, then an action will occur. The code might start like this if guess==”answer”:

Variables Calculate Amounts

Variables can be used in mathematical formulas. This has many practical applications. For example, a business owner can track employee earnings. The variables wage, hours_worked, and earnings can be placed into the formula earnings=wage*hours_worked.

Create Artwork and Build Games using Variables in Python to Teach Coding

Learning how to use variables in Python can be fun. In TechnoTurtle, the programming activities gradually introduce elementary and middle school students to variables. In this project they use variables to count loops and create spirographs that are random colors. As well, they store player answers to build a Mad Lib word game, a carnival game that awards a prize, and a guessing game. These programming tasks make the purpose of a variable easy to understand. Beginners experience first-hand how variables are used in a program to complete a task.

technoturtle and variables

Learning about variables can be fun.