Setting Up Python
Before we can start coding, we need to install Python on your computer and set up a development environment. This lesson will guide you through installing Python and choosing a code editor that will make your programming journey smooth and enjoyable.
Installing Python
Python 3.11 introduced significant performance improvements, making it up to 25% faster than Python 3.10. Always use the latest stable version for the best experience!
We recommend installing Python 3.11 or later. Python 2 is no longer supported and should not be used for new projects. The installation process varies by operating system, so follow the instructions for your platform below.
Windows Installation:
- Go to python.org/downloads in your web browser
- Click the yellow "Download Python 3.x.x" button for the latest version
- Run the downloaded installer file
- Important: Check the "Add Python to PATH" option before installing
- Click "Install Now" and wait for the installation to complete
Mac Installation:
- Visit python.org/downloads and download the macOS installer
- Open the downloaded .pkg file
- Follow the installation prompts, accepting the default settings
- The installer will automatically configure PATH for you
Linux Installation:
Most Linux distributions come with Python pre-installed. To install or update to the latest version, use your package manager:
# Ubuntu/Debian
sudo apt update
sudo apt install python3 python3-pip
# CentOS/RHEL/Fedora
sudo dnf install python3 python3-pip
# Arch Linux
sudo pacman -S python python-pipCode Editor
While you can write Python code in any text editor, using a proper code editor or IDE will significantly improve your productivity. Here are our top recommendations for beginners:
Visual Studio Code (Recommended for Beginners):
- Free and open-source with excellent Python support
- Large extension ecosystem including Python extensions
- Built-in terminal and Git integration
- Lightweight yet powerful with IntelliSense code completion
- Download from code.visualstudio.com
PyCharm Community Edition:
- Free Python-specific IDE with advanced features
- Excellent debugging and testing tools
- Smart code navigation and refactoring
- Built-in version control and database tools
- Download from jetbrains.com/pycharm/download
Test Your Installation
After installing Python, we need to verify everything is working correctly. Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and test your installation:
# Check Python version
python --version
# or on some systems:
python3 --version
# Start Python interactive shell
python
# or:
python3
# In the Python shell, try this:
print("Hello, CodeSparks!")
print("Python is ready!")
# Exit the Python shell
exit()If you see the Python version number when running the version command, and "Hello, CodeSparks!" appears when you run the print command, congratulations! Your Python installation is working correctly.
If you encounter any issues, double-check that Python was added to your PATH during installation on Windows, or try using python3 instead of python on Mac and Linux systems.
The Python interactive shell (also called REPL - Read-Eval-Print Loop) is a great way to test small code snippets and experiment with Python features. You will use it frequently as you learn!