Teaching a kid to code with Pygame Zero

Teaching a kid to code with Pygame Zero

How can you excite a kid about coding and computers?

As a software developer and father of two children, I think about this question often. A person with software skills can have big advantages in our modern world, so I’d like to equip my kids for their future.

In my home, we play video games together. My children (aged six and four) watch me play through many classics like Super Mario World and The Legend of Zelda: A Link to the Past. They like spending that time with daddy and are really engaged with the video game. When I considered how my six year old son might enjoy coding, using video games as the channel into computing was a very natural idea.

I’ve only recently explored game development myself so making a game with my son seemed like a great idea. When I asked him if he wanted to make a game, of course he said “YES!”

To Scratch or Not to Scratch

Once I confirmed his interest, it was time to figure out what to make. In the past, we tried out ScratchJr. ScratchJr uses a graphical interface and UI blocks to compose a set of actions. The tools that come with ScratchJr include looping, counting, and many of the other core things that belong in software development. My experience watching my son showed that ScratchJr was too far removed from programming.

ScratchJR user interface

At first, my son would drag little characters onto the screen and make them jump up and down or move from one side to the other. Later, his play transformed into using the application as a glorified paint program. He would record clips of his voice, change the colors of the characters, and mess around with the scene in countless other ways. I love art and have absolutely no issue with him pursuing artistic interests, but ScratchJr wasn’t teaching programming skills. I don’t know if the actions were too limited, or if he didn’t see the tool as a way to make interactive things.

When I considered our game project, the ScratchJr experience made me rule out Scratch, the more advanced version of building block programming. I also listened to an excellent episode of Talk Python To Me that helped re-enforce my belief that Scratch was not the path to take. In the episode, Michael interviewed Nicolas Tollervey about Teaching Python with the BBC micro:bit.

Nicholas made an awesome point that stuck with me. As a trained musician, he noted that musical instruction teaches kids on real instruments (albeit smaller to fit the size of children). Kids develop musical skills with real instruments, and these skills are directly transferible when a kid gets a larger version of the instrument as they grow. We know this system works because it’s how kids have learned instruments for hundreds of years. His point was this: if musical instruction demonstrates how to teach a kid a complex skill like playing an instrument, why shouldn’t we bring this strategy to teaching programming?

At that moment, I became convinced that the best service I could offer my son was to teach him with a programming language with all the features he would need. Naturally, as a long time Pythonista and user group organizer, Python was my obvious choice.

A Kid Running Python

I still had a lot of aspects of this project to figure out. What is the right user interface for a kid who doesn’t know how to touch type yet? Readers of my content may know that I’m a big Vim fan, but I certainly wouldn’t subject my son to that (yet! 😉 ).

Thankfully, there was more gold in that Talk Python To Me episode. Nicholas is also largely responsible for the Mu editor.

Mu user interface

Mu is an editor focused on running Python for beginners. Mu is awesome for beginners. Here are some highlights:

  • Python is included so there is no need to install something extra! This point probably cannot be overstated, because Python has a reputation for being complicated to install.
  • A number of popular packages like requests, matplotlib, and pyserial come preinstalled to lower the barrier further.
  • There is a mode to work directly with Adafruit’s CircuitPython to use hardware and microcontrollers in Python.
  • Game development is possible with the preinstalled Pygame Zero.

That final highlight is the clear reason why I chose to use Mu for my son.

Pygame Zero Versus Pygame

Pygame Zero is a tool for making video games. It is separate, but related to Pygame, a long-lived Python project that let’s you build (mostly 2-D) games using Python.

The differences between Pygame Zero and Pygame are related to the target audience. I think the Pygame Zero documentation states their project goal well:

[Pygame Zero] is intended for use in education, so that teachers can teach basic programming without needing to explain the Pygame API or write an event loop.
I mentioned at the start of this article that I was learning how to write games too. In my personal exploration of game development, Pygame was my primary choice for writing games. (Truthfully, I started with LÖVE to experiment with Lua and made a Pong clone, but I concluded Lua wasn’t for me.)

The short version of my experience with Pygame is that it’s not very beginner friendly. I’ve learned quite a bit about game development since I started a couple of years ago. When I view Pygame today, it seems more like a game library than a game engine. All the pieces are in place to make a game, but you have to wire everything together yourself. Long time game developers may love this flexibility, but it’s fairly overwhelming to new developers. And it would border on impossible for a six year old kid.

When I tried out Pygame Zero, I was surprised how different the experience was. Pygame Zero is much more like a game engine. The common pieces that you must handle yourself in Pygame are pre-wired in Pygame Zero. This dramatically lowers the barrier to entry, at the cost of flexibility. It’s absolutely the right trade-off for teaching.

What Did We Make?

After all that research, we made our first game in Pygame Zero. Let’s look at my son’s code, then explore the things he learned as well as the things I learned in the process.

First, here’s his entire first game.

slimearm = Actor('alien')
slimearm.topright = 0, 10

WIDTH = 712
HEIGHT = 508

def draw():
    screen.fill((240, 6, 253))

def update():
    slimearm.left += 2
    if slimearm.left > WIDTH:
        slimearm.right = 0

def on_mouse_down(pos):
    if slimearm.collidepoint(pos):
        print("you missed me!")

def set_alien_hurt():
    slimearm.image = 'alien_hurt'
    clock.schedule_unique(set_alien_normal, 1.0)

def set_alien_normal():
    slimearm.image = 'alien'

And here’s a screenshot from the game running:

First game!

His entire game fits into 29 lines of code, including blank lines. In this 29 lines of code, he was able to learn an enormous amount of stuff. Also, to give credit where it is due, the game is a modified version of the one listed in the Pygame Zero introduction. If your eyes are hurting, you can thank my son for the hot pink color choice. The documentation used black, which might be a better fit for outer space.

What Did He Learn?

If you’ve been writing code for a long time, it’s super easy to forget the things that are hard or weird in programming.

Seeing a new programmer wrestle with core concepts is a great reminder that programming is hard, and we must be vigilant in our empathy to those who haven’t walked the path we walked.### Naming Things

In the very first line of the game, my son had to deal with variables.

slimearm = Actor('alien')

Variables (especially for someone who hasn’t done Algebra) are a pretty weird concept. I explained how variables are names for something else and how the name could be whatever we wanted. Because our program took many weekends to complete, we revisited the variables concept each time. Ultimately, I found that the best way to show how little the names mattered was to suggest we change the name alien in the documentation to something else. Thus, slimearm, his choice, was born.

Using a different variable name helped give him ownership of the code he wrote. We had conversations about how he would have to use his slimearm name instead of what he was seeing from the documentation page.


My son also learned how malleable software can be. Pygame Zero made this extremely easy to show.

WIDTH = 712
HEIGHT = 508

Setting the window size for the game requires nothing more than changing WIDTH and HEIGHT. My son would:

  • Fiddle with the numbers.
  • Start the game to see the result, then stop it again.
  • Pick some crazy values.
  • Start the game to see a wacky window size.
  • Repeat until he was happy.

Now that I think about it, kids would make for amazing Quality Assurance engineers given their pension to explore and try things out.

Functions and Side Effects

I think what makes video games so magical as programs for teaching is the effects they produce.

Our industry has an odd obsession with thinking about side effects. Entire modes of programming try extremely hard to minimize side effects. What’s odd to me is that side effects like I/O or drawing to a screen are often the parts that we actually care about and want to see!

Games are really neat because they embrace side effects fully. Since the side effects show us that our code is doing things, they bring a lot of satisfaction.

When I got to the draw function, my son got what he came to see: the computer doing something that he wrote! These were the side effects in action.

def draw():
    screen.fill((240, 6, 253))

This draw function has no return statement. Each time you call it, the results will be different because of the state of slimearm. In other words, it fails to be a “purely functional” function since it has side effects. Maybe this makes higher education academics cringe, but it’s great for kids.

When we first started draw, we dealt with screen.fill as the first side effect. In my home, we’ve played with Arduino circuits regularly so my children know what LEDs are, and my son understands that an LED has red, green, and blue lights in it. I didn’t bother explaining tuples, but I told him that the three numbers to fill were RGB. We fired up Chrome DevTools, launched a color picker, and he dragged around until we found the “perfect” color.

Hoooooot pink!

State and Time

Before we could see the effects of slimearm.draw in the draw function, we needed to update the state of the alien to advance its position.

def update():
    slimearm.left += 2
    if slimearm.left > WIDTH:
        slimearm.right = 0

When I reached this stage, I had to find a method to explain how Pygame Zero alternates between draw and update to make the game run. It’s an example of the Update Method Pattern. 1

I used the idea of a filmstrip to illustrate the concept. In hindsight, this probably wasn’t the best metaphor since my son was born in 2012. We are well into the digital age for most video production so film is a rarity.

The game loop as a filmstrip

After I explained how film worked, my son latched onto the idea of frames as individual images that are drawn on the screen. We talked about how update is in between the frames and causing the frames to be different from each other. He seemed to understand the idea, but then we had to explore coordinates and (x, y) pairs and more concepts from Algebra that he has not studied yet!

So, I went back to the drawing board, literally. The best way I could think to explain how things worked in a 2D coordinate space was with a paper prototype.

Our paper prototype

Our paper prototype was an extremely useful visual tool. With the prototype, I made a game window and our alien character which I labeled as slimearm to match the variable name. Using the two separate pieces of paper, my son could see, in a very visual way, how the character would move. By anchoring on the filmstrip concept, we iterated through the game loop each frame. Since he could point to the various parts, like the left edge which advanced in the update method, he was able to understand how the computer changed the position of the alien.

The labels also helped him get a grasp on the conditional logic. By asking in each loop “Is slimearm’s left edge farther over than the window width?,” it became clear when the alien should be positioned back on the left side and with what edge of the sprite.

Interacting with the Game

Games aren’t really games until you can do something in them. The point of this game is to try and click the alien. If you click it, you’ll hear a little sound, and see the alien temporarily change into a hurt image.

def on_mouse_down(pos):
    if slimearm.collidepoint(pos):
        print("you missed me!")

We started with the concept of events. Being a digital native, my son had no trouble with thinking about actions like touching a screen. It took a bit of explanation to understand a “mouse down” event, but we used the trusty print function to illustrate the idea quickly.

Mu’s game mode has a built-in console that you can see in the editor while the game is running. Our first version of the function above looked more like this:

def on_mouse_down(pos):
    print('You clicked!')

Even this simple level of interaction was enough to make my son light up. I’d try to talk to him about something, but he would start up the game and click around to see an endless stream of “You clicked!” messages show up in the console. It turns out that low tech feedback is enough to get kids really excited!

When we moved up to the full function, I had to explain collisions. Thankfully, the paper prototype made this easy because we could make a game out of the game. I told my son to pretend to play the game while I was the computer. I’d slide the alien cutout along and yell out “Eek!” or “You missed me!“ as he would try to tap on it. Not only did this make us both smile, but the idea of colliding was really natural because of the real world analogue.

def set_alien_hurt():
    slimearm.image = 'alien_hurt'
    clock.schedule_unique(set_alien_normal, 1.0)

When we got to the set_alien_hurt function, we were really dealing with the juice of the game by adding sound effects and changing sprite images. The trickiest part of this was to explain computer clocks and the purpose of the line:

    clock.schedule_unique(set_alien_normal, 1.0)

I’m still not sure if he latched onto this concept or not. Frankly, we had nearly everything working so his interest in adding more code waned rapidly. schedule_unique is a challenging bit of code. You need to understand that functions are things that can be passed around like variables. You also need to wrestle with the idea that set_alien_normal will be called some time in the future and not by code that you wrote. I didn’t belabor this point in the code because we definitely reached the limits of his curiosity.

That brings us to the end of his game code. My son covered:

  • Naming
  • Mutability
  • Functions and side effects
  • State and time, and
  • Interaction

That’s a pretty amazing list of topics for almost any programmer!

What Did I Learn?

Let’s close this out with some of my personal lessons as a teacher. Some of the lessons were reminders of things I knew, but some of these were new lessons. I’m a parent of a kid who is just starting to come into his own and take ownership of his learning, so I’m learning how to help him best.

Repetition, Repetition, Repetition

And one more time: repetition. For most of us, our brains don’t lock-on to concepts after the first exposure. We need to experience things repeatedly for the concepts to sink in. I saw this as my son grappled with variables. Each week as he recalled variables, I had to remind him of what they were for.

If I wasn’t prepared for this kind of behavior, it would be effortless to get irritated. Since I’ve dealt with variables for years, I am so far removed from that first exposure that I barely recall what it was like. Exercising patience was my solution when it felt like he wasn’t mastering concepts.

Feedback Is Critical

I observed that my son was most interested when the computer would do something based on his input. Whether it was showing colors, displaying text, making sounds, or whatever else, he would delight in those moments of feedback. This is what brought me satisfaction as well. Seeing the joy on your child’s face as they latch onto an idea is one of those rewards of being a parent. 2

Use Props

Kids learn in multiple ways. When I hit a wall explaining some ideas with words, switching to a paper prototype dramatically improved the education experience for both of us. Not only was it a quick craft we could do together, but it was a fabulous aide in this process.

Recognize the Limits

Do I think my son would be able to make a game on his own now? Certainly not. I had to remember that there are limits to how much he would retain as we made this game. I didn’t expect him to become an amazing programmer after we finished. This meant that when we ran into some of the harder concepts, I would push a little to make him stretch his thinking, but back off when it was clear he wasn’t ready for an idea yet.


Anyone who knows me well will know that I can be fairly stoic. This was not the time to be stoic. Making a game comes with a certain amount of intrinsic reward, but I also wanted my son to see a very clear extrinsic reward. Learning to program is difficult and making something that works (even if it comes from a documentation tutorial) is a feat worth celebrating for sure.

How many kids manage to make their own functioning video game? I’m sure that number is small in the scheme of things. So, I tried my best to get out of my normally stoic shell and celebrate with my son. In doing that, he could appreciate what he accomplished with someone who understood the project and cares for him.

Now What?

It didn’t take long before he started to have ideas of his own about the next game that we can make together. That game is still in the planning and ideation phases, but he’s excited to work on one.

That’s exactly the outcome I was hoping for. My son now sees programming as a tool for making things. And, I think the world could use more makers.

If you’ve enjoyed this article, would you mind sharing it on Twitter or your favorite social media so that others have the chance to learn something too?

What's Python IDLE? How to use Python IDLE to interact with Python?

What's Python IDLE? How to use Python IDLE to interact with Python?

In this tutorial, you’ll learn all the basics of using **IDLE** to write Python programs. You'll know what Python IDLE is and how you can use it to interact with Python directly. You’ve also learned how to work with Python files and customize Python IDLE to your liking.

In this tutorial, you'll learn how to use the development environment included with your Python installation. Python IDLE is a small program that packs a big punch! You'll learn how to use Python IDLE to interact with Python directly, work with Python files, and improve your development workflow.

If you’ve recently downloaded Python onto your computer, then you may have noticed a new program on your machine called IDLE. You might be wondering, “What is this program doing on my computer? I didn’t download that!” While you may not have downloaded this program on your own, IDLE comes bundled with every Python installation. It’s there to help you get started with the language right out of the box. In this tutorial, you’ll learn how to work in Python IDLE and a few cool tricks you can use on your Python journey!

In this tutorial, you’ll learn:

  • What Python IDLE is
  • How to interact with Python directly using IDLE
  • How to edit, execute, and debug Python files with IDLE
  • How to customize Python IDLE to your liking

Table of Contents

What Is Python IDLE?

Every Python installation comes with an Integrated Development and Learning Environment, which you’ll see shortened to IDLE or even IDE. These are a class of applications that help you write code more efficiently. While there are many IDEs for you to choose from, Python IDLE is very bare-bones, which makes it the perfect tool for a beginning programmer.

Python IDLE comes included in Python installations on Windows and Mac. If you’re a Linux user, then you should be able to find and download Python IDLE using your package manager. Once you’ve installed it, you can then use Python IDLE as an interactive interpreter or as a file editor.

An Interactive Interpreter

The best place to experiment with Python code is in the interactive interpreter, otherwise known as a shell. The shell is a basic Read-Eval-Print Loop (REPL). It reads a Python statement, evaluates the result of that statement, and then prints the result on the screen. Then, it loops back to read the next statement.

The Python shell is an excellent place to experiment with small code snippets. You can access it through the terminal or command line app on your machine. You can simplify your workflow with Python IDLE, which will immediately start a Python shell when you open it.

A File Editor

Every programmer needs to be able to edit and save text files. Python programs are files with the .py extension that contain lines of Python code. Python IDLE gives you the ability to create and edit these files with ease.

Python IDLE also provides several useful features that you’ll see in professional IDEs, like basic syntax highlighting, code completion, and auto-indentation. Professional IDEs are more robust pieces of software and they have a steep learning curve. If you’re just beginning your Python programming journey, then Python IDLE is a great alternative!

How to Use the Python IDLE Shell

The shell is the default mode of operation for Python IDLE. When you click on the icon to open the program, the shell is the first thing that you see:

This is a blank Python interpreter window. You can use it to start interacting with Python immediately. You can test it out with a short line of code:

Here, you used print() to output the string "Hello, from IDLE!" to your screen. This is the most basic way to interact with Python IDLE. You type in commands one at a time and Python responds with the result of each command.

Next, take a look at the menu bar. You’ll see a few options for using the shell:

You can restart the shell from this menu. If you select that option, then you’ll clear the state of the shell. It will act as though you’ve started a fresh instance of Python IDLE. The shell will forget about everything from its previous state:

In the image above, you first declare a variable, x = 5. When you call print(x), the shell shows the correct output, which is the number 5. However, when you restart the shell and try to call print(x) again, you can see that the shell prints a traceback. This is an error message that says the variable x is not defined. The shell has forgotten about everything that came before it was restarted.

You can also interrupt the execution of the shell from this menu. This will stop any program or statement that’s running in the shell at the time of interruption. Take a look at what happens when you send a keyboard interrupt to the shell:

A KeyboardInterrupt error message is displayed in red text at the bottom of your window. The program received the interrupt and has stopped executing.

How to Work With Python Files

Python IDLE offers a full-fledged file editor, which gives you the ability to write and execute Python programs from within this program. The built-in file editor also includes several features, like code completion and automatic indentation, that will speed up your coding workflow. First, let’s take a look at how to write and execute programs in Python IDLE.

Opening a File

To start a new Python file, select File → New File from the menu bar. This will open a blank file in the editor, like this:

From this window, you can write a brand new Python file. You can also open an existing Python file by selecting File → Open… in the menu bar. This will bring up your operating system’s file browser. Then, you can find the Python file you want to open.

If you’re interested in reading the source code for a Python module, then you can select File → Path Browser. This will let you view the modules that Python IDLE can see. When you double click on one, the file editor will open up and you’ll be able to read it.

The content of this window will be the same as the paths that are returned when you call sys.path. If you know the name of a specific module you want to view, then you can select File → Module Browser and type in the name of the module in the box that appears.

Editing a File

Once you’ve opened a file in Python IDLE, you can then make changes to it. When you’re ready to edit a file, you’ll see something like this:

The contents of your file are displayed in the open window. The bar along the top of the window contains three pieces of important information:

  1. The name of the file that you’re editing
  2. The full path to the folder where you can find this file on your computer
  3. The version of Python that IDLE is using

In the image above, you’re editing the file myFile.py, which is located in the Documents folder. The Python version is 3.7.1, which you can see in parentheses.

There are also two numbers in the bottom right corner of the window:

  1. Ln: shows the line number that your cursor is on.
  2. Col: shows the column number that your cursor is on.

It’s useful to see these numbers so that you can find errors more quickly. They also help you make sure that you’re staying within a certain line width.

There are a few visual cues in this window that will help you remember to save your work. If you look closely, then you’ll see that Python IDLE uses asterisks to let you know that your file has unsaved changes:

The file name shown in the top of the IDLE window is surrounded by asterisks. This means that there are unsaved changes in your editor. You can save these changes with your system’s standard keyboard shortcut, or you can select File → Save from the menu bar. Make sure that you save your file with the .py extension so that syntax highlighting will be enabled.

Executing a File

When you want to execute a file that you’ve created in IDLE, you should first make sure that it’s saved. Remember, you can see if your file is properly saved by looking for asterisks around the filename at the top of the file editor window. Don’t worry if you forget, though! Python IDLE will remind you to save whenever you attempt to execute an unsaved file.

To execute a file in IDLE, simply press the F5 key on your keyboard. You can also select Run → Run Module from the menu bar. Either option will restart the Python interpreter and then run the code that you’ve written with a fresh interpreter. The process is the same as when you run python3 -i [filename] in your terminal.

When your code is done executing, the interpreter will know everything about your code, including any global variables, functions, and classes. This makes Python IDLE a great place to inspect your data if something goes wrong. If you ever need to interrupt the execution of your program, then you can press Ctrl+C in the interpreter that’s running your code.

How to Improve Your Workflow

Now that you’ve seen how to write, edit, and execute files in Python IDLE, it’s time to speed up your workflow! The Python IDLE editor offers a few features that you’ll see in most professional IDEs to help you code faster. These features include automatic indentation, code completion and call tips, and code context.

Automatic Indentation

IDLE will automatically indent your code when it needs to start a new block. This usually happens after you type a colon (:). When you hit the enter key after the colon, your cursor will automatically move over a certain number of spaces and begin a new code block.

You can configure how many spaces the cursor will move in the settings, but the default is the standard four spaces. The developers of Python agreed on a standard style for well-written Python code, and this includes rules on indentation, whitespace, and more. This standard style was formalized and is now known as PEP 8. To learn more about it, check out How to Write Beautiful Python Code With PEP 8.

Code Completion and Call Tips

When you’re writing code for a large project or a complicated problem, you can spend a lot of time just typing out all of the code you need. Code completion helps you save typing time by trying to finish your code for you. Python IDLE has basic code completion functionality. It can only autocomplete the names of functions and classes. To use autocompletion in the editor, just press the tab key after a sequence of text.

Python IDLE will also provide call tips. A call tip is like a hint for a certain part of your code to help you remember what that element needs. After you type the left parenthesis to begin a function call, a call tip will appear if you don’t type anything for a few seconds. For example, if you can’t quite remember how to append to a list, then you can pause after the opening parenthesis to bring up the call tip:

The call tip will display as a popup note, reminding you how to append to a list. Call tips like these provide useful information as you’re writing code.

Code Context

The code context functionality is a neat feature of the Python IDLE file editor. It will show you the scope of a function, class, loop, or other construct. This is particularly useful when you’re scrolling through a lengthy file and need to keep track of where you are while reviewing code in the editor.

To turn it on, select Options → Code Context in the menu bar. You’ll see a gray bar appear at the top of the editor window:

As you scroll down through your code, the context that contains each line of code will stay inside of this gray bar. This means that the print() functions you see in the image above are a part of a main function. When you reach a line that’s outside the scope of this function, the bar will disappear.

How to Debug in IDLE

A bug is an unexpected problem in your program. They can appear in many forms, and some are more difficult to fix than others. Some bugs are tricky enough that you won’t be able to catch them by just reading through your program. Luckily, Python IDLE provides some basic tools that will help you debug your programs with ease!

Interpreter DEBUG Mode

If you want to run your code with the built-in debugger, then you’ll need to turn this feature on. To do so, select Debug → Debugger from the Python IDLE menu bar. In the interpreter, you should see [DEBUG ON] appear just before the prompt (>>>), which means the interpreter is ready and waiting.

When you execute your Python file, the debugger window will appear:

In this window, you can inspect the values of your local and global variables as your code executes. This gives you insight into how your data is being manipulated as your code runs.

You can also click the following buttons to move through your code:

  • Go: Press this to advance execution to the next breakpoint. You’ll learn about these in the next section.
  • Step: Press this to execute the current line and go to the next one.
  • Over: If the current line of code contains a function call, then press this to step over that function. In other words, execute that function and go to the next line, but don’t pause while executing the function (unless there is a breakpoint).
  • Out: If the current line of code is in a function, then press this to step out of this function. In other words, continue the execution of this function until you return from it.

Be careful, because there is no reverse button! You can only step forward in time through your program’s execution.

You’ll also see four checkboxes in the debug window:

  1. Globals: your program’s global information
  2. Locals: your program’s local information during execution
  3. Stack: the functions that run during execution
  4. Source: your file in the IDLE editor

When you select one of these, you’ll see the relevant information in your debug window.


A breakpoint is a line of code that you’ve identified as a place where the interpreter should pause while running your code. They will only work when DEBUG mode is turned on, so make sure that you’ve done that first.

To set a breakpoint, right-click on the line of code that you wish to pause. This will highlight the line of code in yellow as a visual indication of a set breakpoint. You can set as many breakpoints in your code as you like. To undo a breakpoint, right-click the same line again and select Clear Breakpoint.

Once you’ve set your breakpoints and turned on DEBUG mode, you can run your code as you would normally. The debugger window will pop up, and you can start stepping through your code manually.

Errors and Exceptions

When you see an error reported to you in the interpreter, Python IDLE lets you jump right to the offending file or line from the menu bar. All you have to do is highlight the reported line number or file name with your cursor and select Debug → Go to file/line from the menu bar. This is will open up the offending file and take you to the line that contains the error. This feature works regardless of whether or not DEBUG mode is turned on.

Python IDLE also provides a tool called a stack viewer. You can access it under the Debug option in the menu bar. This tool will show you the traceback of an error as it appears on the stack of the last error or exception that Python IDLE encountered while running your code. When an unexpected or interesting error occurs, you might find it helpful to take a look at the stack. Otherwise, this feature can be difficult to parse and likely won’t be useful to you unless you’re writing very complicated code.

How to Customize Python IDLE

There are many ways that you can give Python IDLE a visual style that suits you. The default look and feel is based on the colors in the Python logo. If you don’t like how anything looks, then you can almost always change it.

To access the customization window, select Options → Configure IDLE from the menu bar. To preview the result of a change you want to make, press Apply. When you’re done customizing Python IDLE, press OK to save all of your changes. If you don’t want to save your changes, then simply press Cancel.

There are 5 areas of Python IDLE that you can customize:

  1. Fonts/Tabs
  2. Highlights
  3. Keys
  4. General
  5. Extensions

Let’s take a look at each of them now.


The first tab allows you to change things like font color, font size, and font style. You can change the font to almost any style you like, depending on what’s available for your operating system. The font settings window looks like this:

You can use the scrolling window to select which font you prefer. (I recommend you select a fixed-width font like Courier New.) Pick a font size that’s large enough for you to see well. You can also click the checkbox next to Bold to toggle whether or not all text appears in bold.

This window will also let you change how many spaces are used for each indentation level. By default, this will be set to the PEP 8 standard of four spaces. You can change this to make the width of your code more or less spread out to your liking.


The second customization tab will let you change highlights. Syntax highlighting is an important feature of any IDE that highlights the syntax of the language that you’re working in. This helps you visually distinguish between the different Python constructs and the data used in your code.

Python IDLE allows you to fully customize the appearance of your Python code. It comes pre-installed with three different highlight themes:

  1. IDLE Day
  2. IDLE Night
  3. IDLE New

You can select from these pre-installed themes or create your own custom theme right in this window:

Unfortunately, IDLE does not allow you to install custom themes from a file. You have to create customs theme from this window. To do so, you can simply start changing the colors for different items. Select an item, and then press Choose color for. You’ll be brought to a color picker, where you can select the exact color that you want to use.

You’ll then be prompted to save this theme as a new custom theme, and you can enter a name of your choosing. You can then continue changing the colors of different items if you’d like. Remember to press Apply to see your changes in action!


The third customization tab lets you map different key presses to actions, also known as keyboard shortcuts. These are a vital component of your productivity whenever you use an IDE. You can either come up with your own keyboard shortcuts, or you can use the ones that come with IDLE. The pre-installed shortcuts are a good place to start:

The keyboard shortcuts are listed in alphabetical order by action. They’re listed in the format Action - Shortcut, where Action is what will happen when you press the key combination in Shortcut. If you want to use a built-in key set, then select a mapping that matches your operating system. Pay close attention to the different keys and make sure your keyboard has them!

Creating Your Own Shortcuts

The customization of the keyboard shortcuts is very similar to the customization of syntax highlighting colors. Unfortunately, IDLE does not allow you to install custom keyboard shortcuts from a file. You must create a custom set of shortcuts from the Keys tab.

Select one pair from the list and press Get New Keys for Selection. A new window will pop up:

Here, you can use the checkboxes and scrolling menu to select the combination of keys that you want to use for this shortcut. You can select Advanced Key Binding Entry >> to manually type in a command. Note that this cannot pick up the keys you press. You have to literally type in the command as you see it displayed to you in the list of shortcuts.


The fourth tab of the customization window is a place for small, general changes. The general settings tab looks like this:

Here, you can customize things like the window size and whether the shell or the file editor opens first when you start Python IDLE. Most of the things in this window are not that exciting to change, so you probably won’t need to fiddle with them much.


The fifth tab of the customization window lets you add extensions to Python IDLE. Extensions allow you to add new, awesome features to the editor and the interpreter window. You can download them from the internet and install them to right into Python IDLE.

To view what extensions are installed, select Options → Configure IDLE -> Extensions. There are many extensions available on the internet for you to read more about. Find the ones you like and add them to Python IDLE!


In this tutorial, you’ve learned all the basics of using IDLE to write Python programs. You know what Python IDLE is and how you can use it to interact with Python directly. You’ve also learned how to work with Python files and customize Python IDLE to your liking.

You’ve learned how to:

  • Work with the Python IDLE shell
  • Use Python IDLE as a file editor
  • Improve your workflow with features to help you code faster
  • Debug your code and view errors and exceptions
  • Customize Python IDLE to your liking

Now you’re armed with a new tool that will let you productively write Pythonic code and save you countless hours down the road. Happy programming!

Importance of Python Programming skills

Importance of Python Programming skills

Python is one among the most easiest and user friendly programming languages when it comes to the field of software engineering. The codes and syntaxes of python is so simple and easy to use that it can be deployed in any problem solving...

Python is one among the most easiest and user friendly programming languages when it comes to the field of software engineering. The codes and syntaxes of python is so simple and easy to use that it can be deployed in any problem solving challenges. The codes of Python can easily be deployed in Data Science and Machine Learning. Due to this ease of deployment and easier syntaxes, this platform has a lot of real world problem solving applications. According to the sources the companies are eagerly hunting for the professionals with python skills along with SQL. An average python developer in the united states makes around 1 lakh U.S Dollars per annum. In some of the top IT hubs in our country like Bangalore, the demand for professionals in the domains of Data Science and Python Programming has surpassed over the past few years. As a result of which a lot of various python certification courses are available right now.

Array in Python: An array is defined as a data structure that can hold a fixed number of elements that are of the same python data type. The following are some of the basic functions of array in python:

  1. To find the transverse
  2. For insertion of the elements
  3. For deletion of the elements
  4. For searching the elements

Along with this one can easily crack any python interview by means of python interview questions

Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Python Training

This video on Tkinter tutorial covers all the basic aspects of creating and making use of your own simple Graphical User Interface (GUI) using Python. It establishes all of the concepts needed to get started with building your own user interfaces while coding in Python.

This video on Tkinter tutorial covers all the basic aspects of creating and making use of your own simple Graphical User Interface (GUI) using Python. It establishes all of the concepts needed to get started with building your own user interfaces while coding in Python.

Learn More

☞ Complete Python Bootcamp: Go from zero to hero in Python 3

☞ Complete Python Masterclass

☞ Learn Python by Building a Blockchain & Cryptocurrency

☞ Python and Django Full Stack Web Developer Bootcamp

☞ The Python Bible™ | Everything You Need to Program in Python

☞ Learning Python for Data Analysis and Visualization

☞ Python for Financial Analysis and Algorithmic Trading

☞ The Modern Python 3 Bootcamp

Original video source: https://www.youtube.com/watch?v=VMP1oQOxfM0