Skip to content

Development Environment ​

Python Environment Installation ​

Installing Python ​

Windows Installation ​

  1. Download Python

    • Visit the Python official website
    • Download the latest Python 3.x version
    • Run the installer, remember to check "Add Python to PATH"
  2. Verify Installation

    bash
    python --version
    pip --version

macOS Installation ​

  1. Using Homebrew (Recommended)

    bash
    brew install python
  2. Or 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-pip

Comparison: JavaScript Environment ​

EnvironmentJavaScriptPython
RuntimeNode.jsPython Interpreter
Package Managernpm/yarnpip/conda
Version Managernvmpyenv
Virtual EnvProject-level node_modulesvenv/conda

Development Tools ​

  • 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.py

Running interactively ​

bash
python
>>> print("Hello, World!")
Hello, World!
>>> exit()

Basic Syntax Comparison ​

FeatureJavaScriptPython
Statement EndSemicolon (optional)Newline
Comments// or /* */# or """
StringsSingle or double quotesSingle or double quotes
IndentationOptionalRequired

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 ​

  1. Create a Python file that prints your name and age.
  2. Try running simple calculations in the Python interactive environment.
  3. 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.