The Python shell is a powerful tool that allows you to interact with the Python interpreter and run Python code. In this tutorial, we will go over some of the basic commands and features of the Python shell.
Getting Started
This is what the python shell looks like:

- Open your command prompt or terminal.
- Type
python
(without the quotes) and press Enter. This will start the Python interpreter and open the Python shell. - On Windows, you can also search for "Python" or "IDLE" in the start menu and open the application
- Once the shell is open, you should see the Python version and a prompt
>>>
indicating that the shell is ready to accept input. - You can now start entering Python code and commands into the shell.
Basic Commands
The Python shell allows you to enter and run Python code directly. Here are a few basic commands to get you started:
The below image is "Python IDLE Shell".

- Print statement: Use the
print()
function to display text or the value of a variable. For example, typeprint('Hello, world!')
and press Enter to see the output. - Variables: You can assign values to variables in the Python shell. For example, type
x = 5
to create a variable namedx
with a value of5
. You can then use the variable in later calculations or print statements. - Arithmetic: You can perform basic arithmetic in the Python shell. For example, type
2 + 2
to see the result of the calculation. - Help: You can use the
help()
function to get information about a specific function or module. For example, typehelp(print)
to see the documentation for the print function. - Exit: You can exit the Python shell by typing
exit()
orquit()
and pressing Enter.
Advanced Features
The Python shell also has some advanced features that can be useful for more complex tasks:
- Tab completion: You can use the tab key to autocomplete commands and variable names. This can save time and reduce typing errors.
- History: You can access your command history by pressing the up and down arrow keys. This allows you to quickly recall and edit previous commands.
- Script execution: You can also execute python scripts in the shell by passing the script name as an argument to the python command. For example,
python script.py
In conclusion, the Python shell is a powerful tool that allows you to interact with the Python interpreter and run Python code. By learning some of the basic commands and features, you can use the shell to test and debug your code, as well as perform simple calculations and operations.