Start free trial
Trending New Genres Authors
EnglishEnglish
EspañolSpanish
简体中文Chinese
繁體中文Chinese (Traditional)
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Searching...
SoBrief
PLAY WITH PYTHON (CORE)

PLAY WITH PYTHON (CORE)

Python Programming (Core) (Play With Python
Learn Python's core tools, then turn simple rules into programs you can reason about.
by AK Singh 2021
Listen
Immersive
V2.3
Amazon Kindle Audible
Try Full Access for 3 Days
Unlock listening & more!
Continue

Key Takeaways

Let Python's readable syntax expose the logic instead of burying it in ceremony.

Less syntax, more focus. Python is presented as a general-purpose language whose concise statements make beginner programs easier to read and write. A short print statement or a few assignments can replace the setup required in languages such as C or Java. The book also highlights dynamic typing: a variable's type is inferred from the value assigned, so declarations are not required before use.

Convenience has tradeoffs. Python runs through an interpreter and the Python Virtual Machine, and its libraries support many kinds of applications. The book notes that interpreted execution can affect performance and describes mobile development as a limitation. Those claims reflect the book's 2021 context, not a full comparison of today's Python tools. In Python 3, keyboard input arrives as text, so convert it explicitly before arithmetic.

Analysis

What's useful here is the link between readable code and attention: beginners can devote more effort to tracing a program's logic when they are not first wrestling with extensive syntax. That advantage is not the same as making programming effortless. Dynamic typing removes some declarations, but it also means that errors involving unexpected values may surface during execution. A good learning habit is to pair Python's terseness with deliberate checks of what each variable contains and what type an operation expects.

Choose a collection by what it must preserve, change, or look up.

Four structures, four jobs. A list keeps items in order, allows duplicates, and can be changed. A tuple also preserves order and duplicates, but is meant for contents that should remain fixed. A set holds unique items and supports operations such as union and intersection, but has no positional indexing. A dictionary associates keys with values, making it useful when a program needs to look up information by a meaningful key.

Let the requirement decide. For example, a list can store repeated scores in arrival order, a set can identify distinct entries, and a dictionary can connect student names to marks. Dictionary keys must be unique: assigning a value to an existing key replaces its previous value. The book's examples also show that lists and dictionaries can grow or shrink as a program runs.

Analysis

This is a small but powerful form of data modeling. Selecting a structure is an early decision about which facts matter: order, uniqueness, change, or lookup. That makes the choice resemble designing a compact database schema, not merely picking a convenient container. One useful discipline is to ask what a program must guarantee before choosing a type. If order matters, a set is a poor fit; if repeated values matter, a set silently loses information. Clear choices reduce later corrective code.

Track which objects can change, especially when several names point to one list.

Mutability means changeability. The book uses this term for whether an object's contents can be changed after creation. Numbers, strings, and tuples are described as immutable; lists and dictionaries are mutable. Updating a list element changes that list rather than creating a separate one.

Names can share an object. If `y = x` assigns an existing list to a second name, both names refer to the same object. A change made through either name is visible through the other. To make an independent copy of a list, the book demonstrates slicing or the `copy()` method. This distinction also explains why deleting a name is different from assigning `None`: deletion removes the name, while assignment leaves the name bound to a value.

Analysis

The underlying idea is state ownership. In programming, a surprising change often comes not from the line that changed data, but from another part of the program holding a reference to that same data. This is why aliasing is more than a vocabulary item: it is a way to reason about who can affect shared state. The book's copy examples provide a practical safeguard, though copying a list does not necessarily duplicate objects nested inside it. That matters when collections contain other mutable collections.

Keep equality, identity, membership, and truthiness conceptually separate.

Different questions need different operators. `==` compares values, while `is` checks whether two names refer to the same object. Use `in` or `not in` to test whether an item occurs in a collection. These distinctions matter even when two separate lists contain identical values: they can be equal without being the same object.

Conditions can surprise. Python treats zero and empty strings as false-like, while nonzero numbers and nonempty strings are true-like. Logical `and` and `or` can return one of their operands, not just `True` or `False`. In particular, `bool(

Use conditions to choose a path and loops to repeat a clear rule.

Choose, repeat, or skip. Conditional statements use `if`, `elif`, and `else` to select which block runs. A `for` loop processes each item in a sequence, while a `while` loop continues as long as its condition remains true. The book uses `range()` to generate number sequences and nested loops to build rows and columns in patterns.

Control the loop deliberately. `break` exits a loop, `continue` skips the current iteration, and `pass` marks a block that intentionally does nothing. A loop's `else` block runs only if the loop finishes without hitting `break`. For example, a search can stop when it finds a match; its `else` block can report that no match appeared.

Analysis

Loops are where a beginner starts to see a program as a rule applied repeatedly, rather than as a long list of individual instructions. Nested loops make this especially visible: one loop can represent rows and another the items within each row. The loop else feature is less familiar, so it deserves care. Its condition is tied to whether break occurred, not simply to whether the loop's condition became false. Small hand-traced examples can make that distinction much easier to remember.

Treat strings as immutable sequences, then slice or transform them to create results.

A string has positions. Python strings are sequences of characters, with indexes counting from zero on the left and negative positions counting from the right. A slice selects part of a sequence using a start, stop, and step; the stop position is excluded. A negative step can traverse the string backward, and slicing beyond the available positions does not raise an index error.

Methods create useful outputs. The book demonstrates searching for substrings, counting occurrences, splitting text into a list, joining pieces, changing letter case, and removing surrounding spaces. Strings are immutable, so a replacement does not alter the original string; it produces a new one. Formatting with `format()` lets a program insert values into readable output, including numbers with specified widths or decimal places.

Analysis

Thinking of text as a sequence makes many tasks easier to decompose: reversing a word, selecting alternating characters, or counting letters becomes a matter of positions and transformations. This is a useful bridge from basic syntax to algorithmic thinking. The immutability rule also encourages a clear distinction between input text and a transformed result. When handling real-world text, however, a visible character may not always correspond to one simple position, so the book's character-by-character model is best understood as a foundation.

Put repeated logic in functions with clear inputs and useful return values.

One definition, repeated use. A function groups statements under a name so a program can use that behavior without rewriting it. Parameters describe its inputs, and `return` sends a result back to the caller. Without an explicit return statement, the function returns `None`. A function can also return multiple values, which Python packages together for assignment or iteration.

Make calls readable. The book distinguishes positional arguments, which match parameters by order, from keyword arguments, which identify parameters by name. Default values make some inputs optional, and variable-length arguments allow a function to receive a changing number of values. Global variables are defined outside functions; local variables belong to a function's scope. The `global` keyword allows a function to refer to or reassign a global name.

Analysis

Functions create boundaries that help a reader reason about one task at a time. Their value is not only reuse: naming a calculation or decision gives it a conceptual handle. Explicit inputs and returned outputs also make a function easier to test than one that depends on hidden changes to global state. The book introduces several argument styles, but using every option at once can obscure a function's purpose. A restrained interface, with a few understandable parameters, usually makes the logic easier to maintain.

Use comprehensions for compact transformations and higher-order tools for reusable operations.

Build collections from rules. A list comprehension creates a list by applying an expression to each item in an iterable, optionally keeping only items that meet a condition. The book uses them to square numbers, select even results, and derive information such as word lengths. Set and dictionary comprehensions apply the same general idea to other collection types.

Pass behavior into a tool. A lambda is a small anonymous function, useful when a short operation is needed as an argument. The book combines functions with `filter()` to keep matching values, `map()` to transform each value, and `reduce()` to combine a sequence into one result. For instance, mapping a doubling operation over a list produces a new list of doubled values.

Analysis

These techniques express a common idea from functional programming: describe what should happen to a collection, rather than spelling out every step of the traversal. That can make a short transformation easier to inspect. Concision is not automatically clarity, though. A dense comprehension or a chain of anonymous functions can hide the logic from a beginner. A practical rule is to keep the expression simple, and use a named function or an ordinary loop when the transformation needs explanation.

Give code a home. In the book's terminology, a module is a Python file containing functions, variables, or classes that another file can import. A package groups related modules in a directory; the book describes ` init. py` as the marker that makes the directory a package. Importing a module lets a program reuse its members, while aliases can provide shorter names.

Know how a file is running. The special variable ` name ` distinguishes a file run directly from one imported by another program. Its value is ` main ` when the file is the program being run. This allows code intended only for direct execution to be separated from definitions meant for reuse. Command-line arguments are another input route; the book shows them accessed through `sys.argv` as strings.

Analysis

Modules and packages turn a growing program from one crowded file into parts with recognizable responsibilities. This organization supports reuse, but it also reduces the amount of code a reader must keep in mind at once. The __name__ distinction is an early introduction to a broader software-design principle: a component can offer definitions without performing its full application behavior merely because it was imported. Command-line inputs extend the same separation by letting a program receive values from its environment.

Practice loops by turning each printed pattern into rows, columns, and rules.

Patterns make repetition visible. The book ends with 100 pattern programs that print shapes made from stars, numbers, or letters. Some repeat the same value across a row; others increase or decrease the number of symbols on each line. Nested loops provide a natural way to describe these structures: an outer loop chooses a row, while an inner loop prints what belongs in that row.

Derive the rule before coding. For a right-angled triangle, each new row contains one more symbol than the previous row. For a reversed triangle, it contains one fewer. Number and letter patterns add another decision: whether the printed value depends on the row, the column, or both. Working out those relationships first makes the code easier to build and debug.

Analysis

The pattern exercises are useful because they make invisible control flow visible on the screen. A learner can compare the intended row with the printed row and ask which loop or condition produced the difference. That is a basic form of model checking: test whether an implementation follows a stated rule. The exercises primarily build fluency with loops and formatted output, rather than teaching the full range of software development. They are most valuable when each pattern is treated as a rule to explain, not just an answer to copy.

Analysis

This is an introductory Python textbook organized as a progression from language basics to operators, control flow, strings, collections, functions, modules, and packages. Its final section, 100 pattern programs, shifts from explanation to repetition. The intended audience is beginners who need a first map of Python syntax and practice applying it. Its greatest summarization challenge is breadth: the book functions partly as a reference, so retaining every method would bury the decisions that make the language usable.

The central practical lesson is to match a tool to a task. Choose a list when order and change matter, a tuple when values should remain fixed, a set when uniqueness matters, and a dictionary when values need named keys. Then use loops and functions to express repeatable rules, and modules to organize code as it grows. Across the material, Python's compact syntax reduces ceremony, while its object model rewards careful attention to types, mutability, and references.

The book is most effective when it connects a concept to a small program. Reversing a string, counting letters, or printing a triangle gives beginners a concrete target against which to test their reasoning. Its many pattern exercises offer repetition, though readers may learn more by explaining the row and column rules than by reproducing finished code. The treatment is introductory rather than a guide to production software: testing, debugging strategy, error handling, and larger design decisions receive limited attention.

The source was published in 2021 and includes material tied to older Python versions. Some details need version-aware reading: Python 3.7 and later guarantee dictionary insertion order, unlike the book's statement that order is not preserved; Python 3 removed `cmp()` and the `imp` module used in examples. These details do not erase the book's value as a syntax primer, but readers should verify version-sensitive behavior against the Python version they use. The strongest adaptation therefore preserves durable mental models and treats specific runtime claims with care.

Summary in 30 Seconds
Choose lists for ordered, changeable data, tuples for fixed collections, sets for unique items, and dictionaries for key-based lookup. Separate value equality from object identity, and remember that two names can refer to the same mutable object. Conditions and loops direct program flow; functions make reusable operations, while comprehensions transform collections concisely. Modules group related code, and 100 pattern exercises build practice with nested loops.
Contains spoilers

Last updated:

Report Issue
Want to read the full book?

Glossary

Mutability

Whether contents can change

Mutability describes whether an object's contents can be changed after the object is created. In this book, lists and dictionaries are examples of mutable objects, while strings, tuples, and fundamental numeric types are treated as immutable. The distinction matters because changing a mutable object affects every name referring to it, while an attempted change to an immutable value requires a different object.

Aliasing

Multiple names, one object

Aliasing occurs when more than one variable name refers to the same object. Assigning one list variable to another does not create a separate list. A change made through either name is therefore visible through both. The book contrasts this with cloning, in which a separate list is created using slicing or the copy() method.

List Comprehensions

Compact collection construction

A list comprehension creates a list by applying an expression to items from an iterable, with an optional condition that filters which items are included. It can replace a longer loop when the transformation is simple. The book also demonstrates related comprehension forms for sets and dictionaries, using the same general pattern to build different collection types.

Variable Length Arguments

Flexible function inputs

Variable length arguments let a function accept a changing number of inputs. In the book's examples, a parameter marked with * gathers positional values into a tuple, while ** gathers keyword arguments into a dictionary. These forms allow flexible calls, but the function must still make clear how it uses the collected values.

Function Aliasing

Another name for a function

Function aliasing assigns an existing function object to another name. The function can then be called through either name, because both names refer to the same function. Removing one name does not remove the function if another reference remains. The book uses the concept to illustrate its broader claim that functions, like other Python values, are objects.

Module

Reusable Python file

A module is a Python file that can contain functions, variables, and classes. Another program can import the module and use its members, with either the module name or selected imported names. Modules support reuse and help divide a program into parts. The book also covers aliases and the special __name__ variable when working with imported files.

Package

A group of related modules

A package is a directory used to group related Python modules, and a package may contain subpackages. The book describes an __init__.py file as the marker for a package. Packages help keep components identifiable and organized, and importing a module through its package path makes its place in a larger code structure explicit.

Command Line Arguments

Inputs supplied when launching

Command-line arguments are values supplied when a Python program is started. The book accesses them through sys.argv, a list whose first item is the program name and whose following items contain the supplied arguments. Those argument values are strings, so a program must convert them when it needs numbers or another data type.

__name__

Identifies direct execution

Python assigns the special variable __name__ to a module. When a file is run directly, its value is __main__; when the file is imported, the value is its module name. A program can use this distinction to keep reusable definitions available to imports while running startup code only when the file itself is launched.

Download PDF

To save this PLAY WITH PYTHON (CORE) summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.31 MB     Pages: 15

Download EPUB

To read this PLAY WITH PYTHON (CORE) summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 1.35 MB     Pages: 18
Want to read the full book?
Follow
Listen
Home
Swipe
Library
Get App
Try Full Access for 3 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
Read unlimited summaries. Free users get 3 per month
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
—
❤️ Unlimited Bookmarks
Free users are limited to 4
—
📜 Unlimited History
Free users are limited to 4
—
📥 Unlimited Downloads
Free users are limited to 1
—
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 26,000+ books. That's 12,000+ hours of audio!
Day 2: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 3: Your subscription begins
You'll be charged on Nov 24,
cancel anytime before.
Consume 2.8× More Books
2.8× more books Listening Reading
Our users love us
600,000+ readers
Trustpilot Rating
TrustPilot
4.6 Excellent
This site is a total game-changer. I've been flying through book summaries like never before. Highly, highly recommend.
— Dave G
Worth my money and time, and really well made. I've never seen this quality of summaries on other websites. Very helpful!
— Em
Highly recommended!! Fantastic service. Perfect for those that want a little more than a teaser but not all the intricate details of a full audio book.
— Greg M
Save 62%
Yearly
$119.88 $44.99/year/yr
$3.75/mo
Monthly
$9.99/mo
Start a 3-Day Free Trial
3 days free, then $44.99/year. Cancel anytime.
Unlock a world of fiction & nonfiction books
26,000+ books for the price of 2 books
Read any book in 10 minutes
Discover new books like Tinder
Request any book if it's not summarized
Read more books than anyone you know
#1 app for book lovers
Lifelike & immersive summaries
30-day money-back guarantee
Download summaries in EPUBs or PDFs
Cancel anytime in a few clicks

Why one summary?

Scanner
Find a barcode to scan

⭐
⭐
⭐
We have a special gift for you
Open
38% off
DISCOUNT FOR YOU
⭐
⭐
⭐
$79.99
$49.99/year
Only $4.16 per month
Continue
2 taps to start, super easy to cancel
Settings
General
Widget
Loading...