This page will hopefully give you all that you need to get your started with Python.
Python is a scripting language where you write code in files with the .py
extension, such as myfirstfile.py
. File names can’t have spaces, but underscores (_
) and dashes (-
) are allowed, so my_first_file.py
or my-first-file.py
are perfectly fine.
IDLE is Python’s built-in editor, designed to help beginners start writing and running Python code quickly.
Download and install it from https://www.python.org/downloads/
After installing Python, IDLE is usually available in your applications or start menu as "IDLE (Python x.x)". Open it to see two windows: the Python Shell (where you can type and immediately run Python code) and the Editor (where you can save and run code files).
In the IDLE menu, go to File → New File. A new editor window will open. Type some Python code into the editor, such as:
print("Hello from IDLE!")
Go to File → Save As… and name your file, for example, my_first_file.py
. Choose a location you can easily access, like your Desktop or a specific project folder.
In the editor window, go to Run → Run Module (or press F5
on your keyboard). The output will appear in the Python Shell window, displaying:
Hello from IDLE!
IDLE makes it easy to test small scripts quickly, but for larger projects, many developers use a more advanced editor like VS Code.
VS Code is a powerful, free editor that’s popular for all kinds of programming, including Python. Here’s how to use it for Python scripting.
Download from https://code.visualstudio.com/download
If you haven’t already, download and install VS Code. Open VS Code and go to the Extensions view (by clicking the square icon on the sidebar or pressing Ctrl+Shift+X
). Search for Python and install the official Python extension by Microsoft. This will enable Python-specific features.
Open a new file by going to File → New File. Save it as my_first_vscode_file.py
by going to File → Save As… and choosing a location.
In your new file, add Python code like this:
print("Hello from VS Code!")
Make sure the Python interpreter is set up in VS Code (the Python extension should automatically detect it). There are several ways to run your code:
python my_first_vscode_file.py
Your output should display in the Terminal:
Hello from VS Code!
For projects that involve installing additional packages, you might want to set up a virtual environment.
python -m venv myenv
Activate the environment:
myenv\Scripts\activate
source myenv/bin/activate
Once activated, VS Code will use this environment for running your Python code. You can deactivate it by typing deactivate
in the terminal.
By following these steps, you’ll be able to write, save, and test your Python code easily using either IDLE or VS Code, giving you flexibility across different tools!