micheledpierri.com

  • HOME
    • Python
    • Statistics
    • Data Analysis
    • Machine Learning
  • WRITINGS
  • VISIONS
  • ABOUT
Home / Python / Why Python
Children dressed in lab coats are studying a python

Why Python

Why Python Is the Language We Use for Statistics, Data Analysis, and Machine Learning

When people start learning statistics, data analysis, or machine learning, the first question often sounds deceptively simple: which language should I use?

R, Python, MATLAB, Excel, no-code tools — the list is long, and advice is often contradictory. What is rarely explained is that the choice of a programming language is not just a technical decision. It is a methodological choice. It shapes the way you think about data, the way you reason about uncertainty, and ultimately the way you make scientific decisions.

This site uses Python everywhere — not because it is fashionable, and not because “everyone uses it”, but because Python aligns remarkably well with how statistical and scientific reasoning actually works.

Python was not designed to impress computers. It was designed to be read by humans. Its syntax is explicit, almost conversational, and this matters more than it might seem at first. In statistics and medicine, clarity is not a luxury: it is a safety feature. Code that is easy to read is easier to verify, easier to question, and easier to trust. When you write a formula in Python, you can usually recognize the mathematical idea behind it immediately. There is very little distance between the concept you have in mind and the code you write to express it.

This becomes crucial as soon as you move beyond toy examples. Real data is messy. Clinical data in particular is incomplete, inconsistent, and full of edge cases. Before you compute a mean, a p-value, or train a model, you must decide what to do with missing values, how to interpret ambiguous inputs, and how to encode real-world phenomena into something a computer can process. Python forces you to confront these questions explicitly. It does not hide them behind magical defaults. If something is unclear, Python usually makes that unclarity visible: and that is exactly what you want in scientific work.

Another reason Python is used throughout this site is continuity. With Python, you do not learn one language for data cleaning, another for statistics, and another for machine learning. You start with simple scripts, then gradually introduce more structure, more abstraction, more power, without changing tools or mental models. The same language that you use to clean a small dataset is the one you will later use to build a statistical model, evaluate it, and eventually deploy it in a real application. This continuity dramatically reduces cognitive load and makes learning cumulative rather than fragmented.

Python also encourages a way of working that is particularly well suited to science: step-by-step reasoning. You can inspect intermediate results, print values, check assumptions, and verify each transformation before moving on. This is not an accident; it is a consequence of Python’s design philosophy. In statistical analysis, understanding how you arrived at a result is often more important than the result itself. Python supports this kind of transparency naturally.

When it comes to machine learning, Python’s strengths become even more evident. Modern machine learning is not just about algorithms; it is about pipelines, feature engineering, evaluation, iteration, and reproducibility. Python’s core concepts (functions, classes, modules) map cleanly onto these ideas. Models become objects, transformations become functions, and entire workflows can be expressed as readable, inspectable code. This makes complex systems understandable, which is a prerequisite for using them responsibly, especially in medical contexts.

Finally, Python is embedded in an open scientific ecosystem. Libraries for numerical computation, data manipulation, visualization, and machine learning are developed openly, reviewed by large communities, and widely used in research. This openness is not just a philosophical advantage; it has practical consequences. Code can be shared, reviewed, reproduced, and challenged. Assumptions are visible. Errors can be found. Knowledge accumulates.

For all these reasons, Python is not presented here as an end in itself. It is a tool for thinking. A medium through which statistical ideas, data, and models can be expressed clearly and critically. That is why this course begins with Python, and why Python will remain the common thread throughout everything that follows on this site.

From this point on, Python is no longer the subject.

It becomes the instrument.


How to Use This Course

A Guide to Learning Python for Statistics, Data Analysis, and Machine Learning

This course is designed to be read slowly and actively, not skimmed.

Its goal is not to teach you “Python commands”, but to help you build a mental model of how Python is used to reason about data, uncertainty, and real-world problems.

For this reason, how you approach the course matters almost as much as the content itself.

The course is structured as a gradual progression. Each lesson introduces a small set of concepts, but those concepts are reused continuously in later lessons. Nothing is isolated. If something feels familiar, that is intentional: repetition with variation is how understanding deepens.

You do not need any prior programming experience. At the same time, you should resist the temptation to rush. Python rewards patience. Many beginners fall into the trap of copying code that “works” without fully understanding what it does. This course is explicitly designed to avoid that pattern. Every piece of code is short, readable, and meant to be understood line by line.

When you encounter code, do not just run it. Read it. Ask yourself:

  • What problem is this line solving?
  • Why is this written in this way and not another?
  • What would break if this line were removed or changed?

If you cannot answer these questions immediately, that is normal. It usually means you should pause, reread the explanation, or go back briefly to a previous lesson. Python learning is not linear; it is iterative.

The exercises at the end of each lesson are not optional. They are deliberately simple, but they force you to produce code rather than recognize it. Even if you think you know the answer, write it yourself. The difference between understanding and illusion of understanding often appears only when you start typing.

You are encouraged to experiment. Change values. Break the code on purpose. Observe the errors. Many of the most important lessons in Python come from seeing what fails and understanding why. Errors are not a sign of incompetence; they are part of the learning process, especially in data-oriented work.

This course uses standard Python and avoids shortcuts whenever possible. Libraries such as pandas, NumPy, or scikit-learn are not introduced immediately on purpose. The goal is for you to understand what those libraries automate before you rely on them. Later, when you do use them, they will feel like natural extensions of ideas you already understand, not like magic.

Finally, remember the broader context. Python here is not an isolated skill. It is the common language that will connect:

  • descriptive statistics
  • data cleaning and exploration
  • modeling and machine learning

As you progress through the site, you should feel that you are not “starting over”, but rather reusing and refining the same core ideas.

If you approach the course in this way, Python will stop feeling like a technical obstacle and start feeling like what it is meant to be: a clear and flexible instrument for thinking with data.

When you are ready, start with Lesson 2.

Cite this article

Pierri, M. D. (2025). Why Python. micheledpierri.com. Permalink

Share:Email·LinkedIn
NextPython & VS Code Setup (From Zero to a Professional Environment) →
Python
  1. Why Python
  2. Python & VS Code Setup (From Zero to a Professional Environment)
  3. Variables, Naming Rules, and Basic Syntax
  4. Core Data Types in Python
  5. Control Flow: Conditions and Loops
  6. Functions and Code Reusability
  7. Collections: Lists, Tuples, Sets, and Dictionaries
  8. Modules, Packages, and File Handling
  9. Errors, Exceptions, and Robust Code
  10. Object-Oriented Programming (OOP) in Python
  11. Intermediate Python: Writing Clean, Pythonic Code
  12. Python Wrap-Up Lesson: A Mini Cardiology Risk-Factor Audit (Step-by-Step)
© 2024–2026 micheledpierri.com · Privacy Policy · Impressum