How does Python handle very large integers?
Python's int type has arbitrary precision, so large values never overflow. Learn how it is stored, what it costs and how the 4300-digit string limit works.
730 posts about Python: questions with answers, tutorials and articles, newest first.
Python's int type has arbitrary precision, so large values never overflow. Learn how it is stored, what it costs and how the 4300-digit string limit works.
Convert between int, float and str with the built-in constructors, understand truncation and rounding, and handle ValueError on bad input.
Learn which values Python treats as false, how any object can control its truth value, and when to use a plain check or an explicit comparison.
Python reads a < b < c as a < b and b < c, evaluating the middle value once. Learn how chaining works, which operators allow it, and where it surprises people.
Learn how +=, -=, *= and the other augmented assignment operators work in Python, why list += mutates in place, and the tuple and scope pitfalls to avoid.
The exponent operator in Python is **, so 2 ** 3 is 8. Learn precedence, right associativity, negative powers, pow() and why ^ is not a power.
Use // to divide and round down, % for the remainder and divmod for both. Learn how negative numbers behave and where these operators are used.
Python variables are names bound to objects, not boxes. Learn identity, aliasing, reference counting and how arguments are passed in modern Python.
Mutable objects change in place; immutable ones never do. See which Python types are which, and how this causes aliasing and default-argument bugs.
Learn how to install boto3, authenticate, call S3 and EC2 from Python, use paginators and waiters, and handle AWS errors correctly.
Python has no const keyword, so constants use UPPER_CASE names and typing.Final. Learn how to make values truly immutable with Enum and frozen types.
Assign several names at once with x, y, z = 1, 2, 3 or give them one value with a = b = 0. Learn unpacking, star names and the list pitfall.
Learn the Python variable naming rules the interpreter enforces, which names fail with a SyntaxError, and how to pick clear, readable names.
Understand what a Python docstring is, where to place it, which styles exist (Google, NumPy, Sphinx) and how help(), doctest and doc tools use it.
Write Python comments with the hash sign, handle multi-line notes, and know when to use a docstring instead. Includes PEP 8 style tips and examples.
Learn what causes an IndentationError in Python, how to read the four common messages, and how to fix them with consistent spaces and editor settings.
Python indentation defines code blocks in place of braces. See the reasoning behind the design, the PEP 8 style, and how to fix common errors.
Learn the exact commands to run a Python script on Windows, macOS and Linux, pass arguments to it, and fix the errors beginners usually hit.
A beginner walkthrough of your first Python program: install Python, write hello.py, run it in the terminal, and add input and f-strings.
The Python REPL is the interactive prompt that runs code as you type it. Learn to start it, explore objects, fix errors and exit cleanly.