Development Environment
Python Environment Installation
Installing Python
Windows Installation
Download Python
- Visit the Python official website
- Download the latest Python 3.x version
- Run the installer, remember to check "Add Python to PATH"
Verify Installation
bashpython --version pip --version
macOS Installation
Using Homebrew (Recommended)
bashbrew install pythonOr download the official installer
- Download the macOS installer from the official website
- Double-click to install
Linux Installation
Most Linux distributions come with Python pre-installed, or you can use a package manager:
bash
# Ubuntu/Debian
sudo apt update
sudo apt install python3 python3-pip
# CentOS/RHEL
sudo yum install python3 python3-pipComparison: JavaScript Environment
| Environment | JavaScript | Python |
|---|---|---|
| Runtime | Node.js | Python Interpreter |
| Package Manager | npm/yarn | pip/conda |
| Version Manager | nvm | pyenv |
| Virtual Env | Project-level node_modules | venv/conda |
Development Tools
Recommended Editors
- VS Code: Cross-platform, supports Python extensions
- PyCharm: Professional Python IDE
- Jupyter Notebook: For data science and interactive programming
Essential Extensions
Recommended extensions for VS Code:
- Python
- Python Extension Pack
- Python Indent
- Python Docstring Generator
Your First Python Program
Hello World
Let's start with the classic "Hello World":
python
# hello.py
print("Hello, World!")Comparison with JavaScript:
javascript
// hello.js
console.log("Hello, World!");Running the Program
Running from the command line
bash
python hello.pyRunning interactively
bash
python
>>> print("Hello, World!")
Hello, World!
>>> exit()Basic Syntax Comparison
| Feature | JavaScript | Python |
|---|---|---|
| Statement End | Semicolon (optional) | Newline |
| Comments | // or /* */ | # or """ |
| Strings | Single or double quotes | Single or double quotes |
| Indentation | Optional | Required |
Variables and Output
python
# Python
name = "Alice"
age = 25
print(f"Hello, {name}! You are {age} years old.")javascript
// JavaScript
const name = "Alice";
const age = 25;
console.log(`Hello, ${name}! You are ${age} years old.`);Exercises
- Create a Python file that prints your name and age.
- Try running simple calculations in the Python interactive environment.
- Compare the syntax differences between Python and JavaScript.
Next Steps
Now that you have a basic Python environment set up, we will learn about variables and data types.