Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

How to Use the Python IDLE Shell

00:00 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 can see. Here, you can see a blank Python interpreter window.

00:16 You can use it to start interacting with Python immediately, testing it out with a short line of code.

00:28 Here you can see print used it to output the string Hello from IDLE! to the 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.

00:43 Next, take a look at the menu. 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 will clear the state of the shell.

00:55 It will act as if you’ve just started a fresh instance of Python IDLE. The shell will forget about everything from its previous state. Here, you can see a variable, x, has been defined with the value of five and printing it out returns that value. However, after the shell has been restarted, x is no longer defined and this generates a NameError.

01:18 You can also interrupt the execution of the shell from this menu or by using the keyboard shortcut, which is typically Ctrl+C. This will stop any program or statement that’s running in the shell at the time of interruption.

01:32 Take a look at what happens when you send a KeyboardInterrupt to the shell.

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

01:53 In the next section of the course. You’ll see how to work with Python files within IDLE.

Become a Member to join the conversation.