PYTHON FUNDAMENTALS: PROGRAMMING FOUNDATIONS / L01PYTHON SETUP AND FIRST STEPS
课程 · 12 · 01 / 12
LESSON 01 · BEGINNER · 45 MIN · ◆ 1 INSTRUMENT

Python Setup and First Steps

Get Python running and write your first programs. Learn about the Python ecosystem and interactive development.

TIP

Learning Objectives: After this lesson, you'll understand what Python is, why it's popular, and be able to write and execute your first Python programs using interactive tools.

What is Programming? A Chef's Perspective

Before we dive into Python, let's understand what programming really means:

Programming is like writing recipes for a very literal robot chef.

Imagine you have a robot in your kitchen that follows instructions EXACTLY as written:

👨‍🍳 The Programming Kitchen

  • The Recipe (Your Code): Step-by-step instructions written in a specific format
  • The Chef (Python): The robot that reads and executes your recipe
  • The Ingredients (Data): The information your program works with
  • The Dish (Output): The result your program produces

Why the chef must be literal:

  • If you write "add some sugar," the chef stops (how much is "some"?)
  • If you write "stir until done," the chef waits forever (when is it "done"?)
  • If you write "add 2 eggs" but there are no eggs, the chef reports an error

Good recipes (programs) must be:

  1. Precise: Every step is clearly defined
  2. Sequential: Steps happen in order
  3. Unambiguous: No room for interpretation
  4. Complete: All necessary information included

This is exactly what programming is - giving precise, unambiguous instructions to a computer!

What is Python?

Python is a high-level, interpreted programming language known for its simplicity and readability. Created by Guido van Rossum in 1991, Python has become one of the most popular programming languages in the world.

Why Python is like a friendly chef:

  • It understands instructions written in near-English
  • It gives helpful error messages when confused
  • It handles many technical details automatically
  • It's forgiving for beginners but powerful for experts

Why Python is Special

FeatureDescriptionExample
Simple SyntaxCode reads like Englishif age >= 18: print("Adult")
InterpretedNo compilation neededRun code immediately
VersatileWeb, data science, AI, automationDjango, pandas, TensorFlow
Large CommunityExtensive libraries and support300,000+ packages on PyPI

Your First Python Program

Let's start with the traditional "Hello, World!" program:

FIG. 02Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 02Interactive Python code execution environment

🎉 Congratulations! You just ran your first Python program. Notice how:

  • print() displays text and values
  • Text (strings) are wrapped in quotes
  • Python can do math calculations
  • Comments start with #

Python as a Calculator

Python excels at mathematical operations. Try these examples:

FIG. 04Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 04Interactive Python code execution environment

Working with Text

Python makes it easy to work with text (called "strings"):

FIG. 06Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 06Interactive Python code execution environment

Interactive Python Features

One of Python's strengths is its interactive nature. You can:

  1. Experiment quickly - Test ideas immediately
  2. Get instant feedback - See results right away
  3. Learn by doing - Try things and see what happens
FIG. 08Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 08Interactive Python code execution environment

Python's Philosophy

Python follows a philosophy called "The Zen of Python." Let's see it:

FIG. 10Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 10Interactive Python code execution environment

Key principles that make Python special:

  • Beautiful is better than ugly - Code should be pleasant to read
  • Simple is better than complex - Prefer straightforward solutions
  • Readability counts - Code is read more often than written

Common Python Use Cases

Python is used everywhere in technology:

🌐 Web Development

  • Frameworks: Django, Flask, FastAPI
  • Companies: Instagram, Spotify, Dropbox

📊 Data Science & Analytics

  • Libraries: pandas, NumPy, matplotlib
  • Companies: Netflix, Uber, Airbnb

🤖 Artificial Intelligence

  • Libraries: TensorFlow, PyTorch, scikit-learn
  • Applications: ChatGPT, image recognition, recommendation systems

🔧 Automation & Scripting

  • System administration
  • Web scraping
  • Task automation

Your Development Environment

In this course, we're using an interactive Python environment that lets you:

  • ✅ Write and run code instantly
  • ✅ See results immediately
  • ✅ Experiment without setup
  • ✅ Learn through hands-on practice
FIG. 12Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 12Interactive Python code execution environment

Practice Exercises

Try these exercises to reinforce what you've learned:

Exercise 1: Personal Introduction

FIG. 14Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 14Interactive Python code execution environment

Exercise 2: Simple Calculator

FIG. 16Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 16Interactive Python code execution environment

Key Takeaways

Python is beginner-friendly - Simple syntax that reads like English
Interpreted language - Run code immediately without compilation
Versatile - Used in web development, data science, AI, and automation
Interactive - Perfect for learning and experimentation
print() - Your primary tool for displaying output
Comments - Use # to document your code

Connections: Programming Languages and Beyond

🔗 Connection to Other Programming Languages

Python is part of a large family of programming languages. Here's how it compares:

PythonJavaScriptJavaC++
print("Hello")console.log("Hello")System.out.println("Hello")cout << "Hello"
No compilationNo compilationCompiles to bytecodeCompiles to machine code
InterpretedInterpretedHybridCompiled
Dynamically typedDynamically typedStatically typedStatically typed

Python's Philosophy:

  • Readability: Code should be easy to read (unlike Perl)
  • Simplicity: One obvious way to do things (unlike C++)
  • Batteries included: Rich standard library (unlike C)

🔗 Connection to Computer Science

Python helps you learn fundamental CS concepts:

  • Algorithms: Step-by-step problem solving
  • Data structures: Organizing information efficiently
  • Logic: Boolean reasoning and decision making
  • Abstraction: Hiding complexity behind simple interfaces

🔗 Connection to Real-World Applications

Python powers systems you use every day:

  • Web: Instagram, Pinterest, Reddit (Django/Flask)
  • Streaming: Netflix, Spotify (data analysis, recommendations)
  • Space: NASA uses Python for mission planning
  • AI: ChatGPT, DALL-E (PyTorch, TensorFlow)
  • Science: Research in physics, biology, astronomy

🔗 Connection to Your Future Learning

This is just the beginning of your Python journey:

  • Next lesson: Variables and data types (your program's memory)
  • Soon: Functions and classes (organizing your code)
  • Later: Web development, data science, or AI (applying Python)
  • Eventually: Building your own applications and tools!

🔗 The Evolution of Programming

Programming languages have evolved like natural languages:

  • 1940s-50s: Machine code (binary 1s and 0s)
  • 1960s-70s: Assembly and early high-level languages (FORTRAN, C)
  • 1980s-90s: Object-oriented languages (C++, Java, Python)
  • 2000s-10s: Web languages and scripting (JavaScript, Ruby, Python grows)
  • 2020s: AI-first languages and tools (Python dominates)

Python represents a major leap in making programming accessible to everyone!

Remember: Every expert programmer started exactly where you are now - with print("Hello, World!")!

Next Steps

In the next lesson, we'll dive deeper into variables and data types - the building blocks of all Python programs. You'll learn how Python stores and manages different types of data in memory.


Ready to continue? The next lesson will show you how Python handles data with variables and introduce you to Python's built-in data types.


Further Reading

Interactive Playgrounds

Official & Free Books

Modern Tooling (use these, not the old pyenv/virtualenv dance)

  • uv — Astral's modern Python package + project manager. Drop-in replacement for pip, pip-tools, pyenv, poetry. Written in Rust, ~10× faster.
  • Ruff — formatter + linter that replaces black, flake8, and isort in one tool. Also from Astral.
  • VS Code Python Extension — the most popular Python editor setup, with the official tutorial.

Video & Community