Chapter 1 of 24 · Python for Beginners — Complete Free Tutorial

Introduction to Python

Welcome to the Python for Beginners series on Scriptly. Across 24 chapters you will go from your first print() call to virtual environments, classes, decorators, type hints, testing with pytest and the asyncio runtime. This first chapter answers the opening questions: what Python is, why it has stayed popular for more than thirty years, how an interpreted language differs from a compiled one, and how Python’s dynamic typing compares with the TypeScript this site teaches next door.

What Python is

Python is a general-purpose programming language created by Guido van Rossum and first released in 1991. Its guiding idea from the beginning was that source code is read far more often than it is written, so the syntax is deliberately plain: English keywords, indentation instead of punctuation, and very little ceremony between an idea and a running program.

  • General-purpose — the same language writes a five-line file-renaming script, a web API, a data pipeline and a machine-learning model.
  • Multi-paradigm — procedural code, object-oriented code and functions used as values all work; you choose per problem, not once per project.
  • Open source — the reference implementation, CPython, is developed in the open, and every Python you will ever install is free.

Why Python stayed popular

Nothing stays near the top of the language rankings for three decades by accident. Three properties keep reinforcing each other:

  • Readability — because indentation defines blocks and keywords are English, a stranger can follow your program on first read. Readable code is cheaper to review, debug and hand over, and considerably easier to learn.
  • Batteries included — the standard library ships modules for files, paths, dates, JSON, CSV, regular expressions, compression, threading, HTTP, email and testing. A surprising number of jobs need only import, not pip install.
  • A huge ecosystem — pip and the PyPI registry add hundreds of thousands of packages: Django, Flask and FastAPI for the web; pandas, NumPy and Matplotlib for data; pytest for testing; requests and httpx for HTTP; Pillow for images.
  • It plays well with others — Python is the classic glue language: call a C, Fortran or Rust library from a short Python script and get readability where you want it and speed where you need it.

The culture fits in a single command. Every interpreter ships the “Zen of Python”, a list of design principles written by Tim Peters:

python3 -m this

Expected output:

The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
...   (14 further lines: read all of them in your own terminal)

Interpreted, not compiled

A compiled language such as C, C++, Go or Rust translates the whole program into machine code before it can run, producing a binary tied to one platform. Python is interpreted: you hand the source to the python3 executable, which parses it, compiles it into an intermediate form called bytecode, and runs that bytecode on the Python virtual machine. The program starts immediately, and the same .py file runs unchanged on Windows, macOS and Linux.

QuestionCompiled (C, Rust)Interpreted (Python)
When does translation happen?Before the program ever runsBytecode is built when you run it, then executed by the virtual machine
What do you ship?A platform-specific binarySource files plus a Python interpreter
Edit-and-run loopRebuild and link, then runSave the file and run it again
Raw speedClose to the hardwareOften 10–100 times slower in pure Python

Two details worth knowing now. First, Python caches bytecode for the modules you import in a __pycache__ folder so later imports start faster; the script you run directly is compiled again each time. Second, interpreted does not mean slow by definition: heavy numeric work lives in C extensions such as NumPy, and Python coordinates them.

Dynamic typing

Python is dynamically typed: a variable is just a name pointing at a value, the value carries the type, and nothing is declared up front. The same name can point at an integer now and at a string a moment later:

value = 10
print(type(value), isinstance(value, int))

value = "ten"
print(type(value), isinstance(value, int))

Expected output:

<class 'int'> True
<class 'str'> False

Dynamic typing buys you speed of writing and lets a function accept whatever it is given. The price is that type mistakes surface at runtime, on the line that finally uses the bad value:

total = "5" + 5
print(total)

Expected output:

Traceback (most recent call last):
  File "convert.py", line 1, in <module>
    total = "5" + 5
            ~~~~^~~
TypeError: can only concatenate str (not "int") to str

That is exactly the gap the TypeScript series on this site closes: static types move the mismatch from a runtime traceback to a red squiggle in your editor. Python can be checked that way too — you will meet its type hints in chapter 20 — but the language itself never requires them, so discipline has to come from you.

Where Python runs

Python’s breadth is the reason beginners meet it everywhere:

  • Scripting and automation — renaming files, cleaning spreadsheets, scraping pages, scheduled jobs, build scripts.
  • Web backends — Django, Flask and FastAPI power everything from small internal tools to very large APIs.
  • Data and machine learning — pandas, NumPy, scikit-learn, PyTorch and TensorFlow are Python-first.
  • Science and academia — Jupyter notebooks are the default computational lab notebook.
  • DevOps and cloud tooling — Ansible, Salt and countless command-line tools are written in Python.
  • Desktop and games — Tkinter, PyQt and pygame cover the rest.

Your first program

No HTML page, no browser, no build step. Create a folder, add a file named hello.py and type this:

name = "Ada"
print("Hello,", name)
print("2 + 2 =", 2 + 2)

Then run it from a terminal opened in that folder:

python3 hello.py

Expected output:

Hello, Ada
2 + 2 = 4

print() writes to the terminal, accepts several arguments and joins them with a single space. Notice that comments start with #, where JavaScript uses // — and that line one was ordinary assignment, with no keyword in front of it.

Python vs JavaScript

If you already read JavaScript, from this site’s JavaScript series or anywhere else, most of Python will feel familiar with the punctuation rearranged. These are the differences that trip people up first:

TopicJavaScriptPython
Where it runsBrowsers and Node.jsAnywhere a Python interpreter is installed
Grouping a blockBraces around the bodyIndentation of the body
Declaring a variablelet, const or varPlain assignment: name = value
Comments// and /* */# only
String interpolationTemplate literals: Hi ${name}f-strings: f"Hi {name}"
"5" + 1"51", silent coercionTypeError, loud failure
Ordered collectionsArray and plain objectslist and dict
“No value”Both undefined and nullOnly None
Running a filenode file.jspython3 file.py

Keep one more contrast in mind: JavaScript coerces without being asked, and data types and type coercion explains why. Python refuses to guess, which is why your first week of Python produces a few honest TypeError tracebacks instead of silent nonsense.

Common mistakes

  • Treating Python as a framework — Python is the language; Django, pandas and pytest are libraries written in it. Learn the language first and the libraries become far easier.
  • Copying JavaScript punctuation — braces, let, ===, // and template literals do not exist here; expect a short adjustment period to indentation and # comments.
  • Assuming dynamic typing means no types — every value has a type at all times; what Python skips is your declaration of it.
  • Expecting the interpreter to protect you — type errors and misspelled names raise exceptions only when the failing line actually runs.
  • Learning only the tutorial subset — skipping the standard library and pip means re-writing things Python already ships.

Practice checklist

  1. Write your own hello.py that prints your name, a calculation and the value 24 * 365, then run it with python3.
  2. Run python3 -m this and read all twenty lines of the Zen of Python; copy down the two that mean the most to you.
  3. Run the dynamic typing snippet, then change value = "ten" to value = 11 and predict type() before you press Enter.
  4. Rewrite the JavaScript comparison table from memory and check it line by line against this chapter.
  5. Name three programs you use daily and write one sentence on what Python could automate in each.

What's next?

You know what Python is and why it endured; now it needs to exist on your machine. Install it, meet the REPL and run your first file — Installing Python and Running Code.

Quiz: Introduction to Python

5 questions · 70% to pass

Frequently Asked Questions

Python is a general-purpose language first released in 1991, designed around one idea: code is read far more often than it is written. English keywords and indentation instead of braces make it readable, the standard library covers files, JSON, dates and testing, and pip adds thousands more packages. The same language handles scripts, web APIs, data work and machine learning.

None at all. Python is widely considered the friendliest first language: no declaration keywords, no braces, no build step, and error messages that name the problem. This series begins at your first print() call. If you already read JavaScript or TypeScript you will adjust quickly, but no previous language is assumed anywhere in these 24 chapters.

Python 3 only, any release from 3.12 onwards. Python 2 reached end of life in 2021 and its print "hi" statements and xrange() no longer run. One historical quirk remains: installers ship the interpreter as python3 on macOS and Linux, while Windows usually offers python or the py launcher, and every command in this series works with that one-word swap.

More than you might expect. Everyday automation such as renaming files, cleaning spreadsheets or scraping pages; web backends with Django, Flask or FastAPI; data analysis and machine learning with pandas, NumPy and PyTorch; DevOps tooling, desktop apps and games. Python is also the classic glue language, calling C, Rust or Fortran libraries from short readable scripts.

Pure Python can run 10 to 100 times slower than C, yet that rarely blocks you: heavy numeric work lives in C extensions such as NumPy, which Python coordinates. Dynamic typing does push errors to runtime, surfacing as a TypeError on the line that finally uses the bad value. Type hints checked by mypy move those mistakes back into your editor.

Only the interpreter. Install CPython from python.org, version 3.12 or newer, confirm it with python3 --version, and open a plain text editor; VS Code with the Python extension is the recommendation here. The early chapters use no third-party packages, so there is nothing else to set up until virtual environments and pip arrive.

A dict is a real runtime mapping: keys may be any hashable value rather than only strings, insertion order has been guaranteed since Python 3.7, and a missing key raises KeyError unless you ask with get(). JavaScript objects coerce every key to a string and carry a prototype chain. A TypeScript interface is erased at compile time and describes shape only; TypedDict is Python's checked equivalent.

Reach for a list when items will be added, removed or reordered: it is ordered, mutable and rich with methods. Pick a tuple for fixed records and function returns, because it is immutable and hashable, so it can be a dictionary key. Choose a set for unique values and fast membership checks; it has no order and de-duplicates on creation.

Yes, gradually. Annotate public function signatures first; the interpreter ignores hints at runtime, so a checker such as mypy is what gives them teeth. Add tests the same way: pytest collects any test_*.py file and plain assert statements, and a suite that finishes in a tenth of a second is one you will run after every change. Both habits cost little now and much more later.

JavaScript and TypeScript keep the browser, so anything rendered to the user stays theirs. Python takes the server: Django for full-featured applications, Flask for small ones, FastAPI for typed async APIs where your annotations become automatic documentation. Your TypeScript habits transfer directly, and asyncio mirrors the event loop you already know, just with different keywords.