Why Python
There are hundreds of programming languages, and every one of them has people who will tell you it is the right place to start. You deserve an honest reason for this choice. Python is readable, it is used almost everywhere, and the places where it is slow almost never matter to the programs a beginner writes, or to most of the programs professionals write either.
Choosing a first language is a little like choosing a working language for travel. English is not the most precise language or the most beautiful one, but it gets you understood in more rooms than any other. Python plays that role among programming languages. Once you are fluent in the ideas, a second language comes much faster, whichever it is.
Readable by Design
Python was designed around one belief: code is read far more often than it is written. So it uses words where many languages use symbols. It says and, or and not rather than pairs of ampersands and bars. And it uses indentation, the spaces at the start of a line, to show which lines belong together, where other languages use curly brackets. The result is code that a newcomer can often read aloud and roughly understand before learning a single rule.
Used Almost Everywhere
Python runs small scripts that rename a thousand files, the backends of large websites, the analysis of scientific data, most of the world's machine-learning work, and the glue that connects one system to another. For a learner that breadth matters: the same language carries you from your first script to real work, and the catalogue's Backend Deep Dive and its machine-learning path both start from the Python this book teaches.
Batteries Included
Python arrives with a large standard library: ready-made tools for files, dates, text, data formats and the internet, installed along with the language itself. Behind it sits a public collection of hundreds of thousands of extra packages written by other people. Chapter 9 shows you both. In practice this means a surprising amount of useful work needs nothing but Python itself.
What Python Is Honestly Bad At
Python is slower than many languages at raw number-crunching, the kind of tight loop that repeats a calculation billions of times. That is why its popular data and machine-learning libraries are written in faster languages underneath, with Python as the friendly layer on top. It is also a poor fit for phone apps, and it is not the language that runs inside a web page in your browser; that job belongs to JavaScript.
For the programs in this book, none of that matters. A script that reads a file, talks to a website or waits for you to type something spends nearly all its time waiting on the file, the network or you. How fast the language itself runs barely shows.
| Kind of work | Is Python a strong choice? |
|---|---|
| Automating everyday tasks | yes, one of its best uses |
| Web backends and services | yes, widely used |
| Data analysis and machine learning | yes, the most common choice |
| Phone apps | rarely; other tools usually win |
| Code that runs inside a web page | no; that is JavaScript's job |
- "Python is a beginner language that professionals outgrow." It runs large parts of the world's software and most machine-learning work. Beginners use it because it is readable, and professionals keep using it for the same reason.
- "A slow language means slow programs." For a script that spends its time waiting on files, networks or people, the language's own speed is almost never the bottleneck.
- "Learning Python first locks me in." Values, decisions, loops, functions and data are the same ideas in every language. The second language is always faster to learn than the first.
- A first language should get out of the way of the ideas. Python does that better than most, which is why it is the first language in so many schools and universities.
- The same skills lead straight into this catalogue's deeper books on building services and on machine learning, with no second language to learn first.
Knowledge Check
Which design choice makes Python easier to read than many languages?
- It uses words and indentation where others use symbols and brackets
- It lets you write instructions in ordinary English sentences instead
- It shows every program as a picture of connected blocks on the screen
- It limits every program to a small number of lines so it stays short
Where is Python honestly a weak choice?
- Small scripts that automate repetitive tasks on your own computer
- The services that run behind websites and answer their requests
- Code that runs inside a web page, and most phone apps
- Data analysis and the training of machine-learning models
Why does Python's speed rarely matter for the scripts in this book?
- Modern computers are fast enough that no language is ever slow
- They spend most of their time waiting on files, networks or people
- Python quietly rewrites slow programs in a faster language for you
- The book only uses short programs that finish within a single second
What does "batteries included" mean for Python?
- Python is designed to save battery power on laptops and phones
- Useful tools are available only after buying a paid edition
- A large library of ready-made tools is installed with the language
- Python includes a visual builder so that you never need to type code
You got correct