Setup Environment
Before we dive into Python programming, we need to set up your development environment. This includes installing Python and choosing a code editor.
Installing Python
- Download Python:
- Visit the official Python website.
- Download the latest version for your operating system.
- Install Python:
- Run the installer.
- Make sure to check the box that says “Add Python to PATH” during installation.
- Follow the installation prompts.
- Verify Installation:
- Open a terminal or command prompt.
- Type the command:
python --version
- You should see the installed Python version.
Choosing a Code Editor
A code editor is where you’ll write your Python code. Here are some popular options:
- VS Code (Recommended):
- Download from Visual Studio Code.
- Install the Python extension for syntax highlighting and debugging.
- PyCharm:
- Ideal for larger Python projects.
- Download from JetBrains PyCharm.
- Other Options: Sublime Text, Atom, or even a simple text editor.
Setting Up VS Code for Python
- Install VS Code:
- Download and install from the official website.
- Install the Python Extension:
- Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+X
). - Search for “Python” and install the extension by Microsoft.
- Verify the Setup:
- Open a new file and save it with a
.py
extension (e.g.,hello.py
). - Type the following code:
print("Hello, Python!")
- Run the file by pressing
Ctrl+Shift+B
or using the Run option.
- Open a new file and save it with a
Testing Your Setup
- Open a terminal in your code editor.
- Navigate to the folder where your Python file is saved.
- Run the file with:
python hello.py
- You should see the output:
Hello, Python!
Now that your environment is ready, you’re all set to begin your Python journey!
Next Lesson: The Terminal