What you will learn in Tiny Python Projects: Learn coding and testing with puzzles and games
Learn coding and testing with puzzles and games
Chapter by chapter
Chapter 6: Words count: Reading files and STDIN, iterating lists, formatting strings
What you learn in chapter 6 →Chapter 9: Dial-a-Curse: Generating random insults from lists of words
What you learn in chapter 9 →Chapter 14: Rhymer: Using regular expressions to create rhyming words
What you learn in chapter 14 →Chapter 19: Workout of the Day: Parsing CSV files, creating text table output
What you learn in chapter 19 →Chapter 20: Password strength: Generating a secure and memorable password
What you learn in chapter 20 →Chapter 22: Tic-Tac-Toe redux: An interactive version with type hints
What you learn in chapter 22 →Concepts explained in this book
- loopA while loop is a Python control-flow construct that repeatedly executes a block while its condition is true.
- regular expressionA regular expression is a pattern notation for matching and extracting text according to specified character and sequence rules.
- listAn empty list is a list containing zero elements.
- character classA character class is a regular-expression construct that matches one character from a specified set or range.
- positional parameterA command-line parameter whose meaning is determined by its position in the argument sequence rather than by an option name.
- file objectA file is a named, persistent container of data managed by a filesystem.
- stringA string is a Python value representing a sequence of text characters.
- MapAn empty dictionary is a dictionary containing no key-value mappings.
- splitstr.split() is a Python string method that divides a string into a list of substrings using a separator or, by default, whitespace.
- subre.sub() is a Python regular-expression function that returns text with matches of a pattern replaced by specified replacement text.
- rere is Python's standard-library module for matching and manipulating text with regular expressions.
- rangerange() is a Python built-in that represents an arithmetic sequence of integers for iteration.
- command-line argumentA command-line argument is a value supplied to a program when it is launched from a command-line interface.
- higher-order functionA higher-order function is a function that accepts another function as an argument or returns a function.
- vowelA vowel is a speech sound or alphabetic letter produced without significant obstruction of airflow, including a, e, i, o, and u in this context.
- argparseargparse is a Python standard-library module for parsing command-line arguments and generating related usage and help information.
- get_argsget_args is a function that collects and validates a program's command-line arguments.
- immutable collectionAn immutable collection is a collection whose membership and contents cannot be changed after creation.
- samplingSampling is a procedure for selecting or generating observations, values, or outcomes from a larger population, signal, or probability distribution according to a specified method.
- lazy evaluationA lazy function defers producing a result until that result is needed.
- closureA closure is a function together with references to variables from its enclosing lexical scope.
- parser.error()parser.error() is an argparse parser method that reports a command-line parsing error, displays usage information, and terminates the program with a failure status.
- slicingSlicing selects or partitions a portion of an indexed sequence or multidimensional array, often along specified indices or dimensions.
- openopen() is a Python built-in function that opens a file and returns a file object for performing input or output.
- CSVA CSV file is a delimited text file that represents tabular records using rows and separators between fields.
- joinstr.join() is a Python string method that concatenates strings from an iterable with the calling string inserted between adjacent elements.
- tupleA tuple is an immutable ordered collection of Python elements.
- named tupleA typed named tuple is an immutable tuple-like record whose fields have names and declared types.
- lineA line is a sequence of text characters ending at a line boundary or the end of a text stream.
- .new.pyA per-user configuration file in the home directory containing name and email values read by new.py.
- regex groupingA capture group is a parenthesized subpattern in a regular expression whose matched text is retained for later retrieval.
- ordord() is a Python built-in function that returns the integer code point of a single character.
- tic-tac-toe boardA Tic-Tac-Toe board is a game grid containing nine cells, each marked with X, O, or an empty marker.
- keyA dictionary key is a hashable object used to identify and retrieve a value in a mapping.
- f-stringAn f-string is a Python string literal that evaluates expressions enclosed in braces and inserts their values into the resulting string.
- chrchr() is a Python built-in function that returns the character represented by an integer code point.
- consonantA consonant is a speech sound produced with constriction or closure in the vocal tract and represented by a non-vowel letter in this exercise.
- argparse.FileTypeargparse.FileType is an argparse factory for creating a command-line argument converter that opens named files with a specified mode.
- one-or-more quantifierA one-or-more quantifier is a regular-expression quantifier requiring the preceding element or group to occur at least once.
- declarative programmingDeclarative programming is a programming paradigm that describes the desired result or rules without specifying every execution step.
- --num--num is a book-specific long command-line option that specifies the number of verses to generate.
- truthinessA truthy value is a Python value that evaluates to true in a Boolean context.
- uppercase conversionA Python string method that returns a copy of the string with its cased characters converted to uppercase.
- sorting algorithmSorting is the operation of arranging collection elements according to an ordering criterion.
- read operationfile.read() reads data from a file object and returns it as a string or bytes according to the file mode.
- format methodstr.format() is a Python string method that produces a new string by replacing formatting fields with supplied values.
- valueA value is the information associated with an attribute or dictionary key.
- dict.getdict.get is a Python dictionary method that returns the value for a key or a specified default when the key is absent.
- password authenticationA password is a secret string of characters used to authenticate a user or protect access to an account or service.
- membership operatorA membership expression tests whether a value occurs in a collection or other container.
- --outfileA command-line option that specifies the file to which program output should be written.
- translatestr.translate() is a Python string method that returns a new string by mapping characters according to a translation table.
- help messageA help message is command-line documentation printed by a program to explain its invocation syntax and available arguments or options.
- verseA book-specific function that generates the text of a verse of the Bottles of Beer song for a supplied bottle count.
- booleanA Boolean value is one of the two truth values, True or False, used to represent logical conditions.
- winnerA winner is the player determined by a game's rules to have achieved the winning condition.
- newlineA newline is a character or character sequence that marks the boundary between consecutive lines of text.
- rstripstr.rstrip() is a Python string method that returns a copy of a string with trailing whitespace characters removed.
- type hintsA type hint is optional Python syntax that annotates the expected types of variables, parameters, or return values without enforcing them during ordinary execution.
- dict()dict() is the Python built-in constructor that creates a dictionary from supplied arguments or creates an empty dictionary when called without arguments.
- built-in functionlist.append() is a Python list method that adds one object as a single new element at the end of the list.
- filteringFiltering is the process of retaining items that satisfy specified selection criteria and removing the others.
- nargsnargs is an argparse argument-definition parameter that specifies how many command-line values an argument accepts.
- sortedsorted is a Python built-in function that returns a new list containing the sorted elements of an iterable without modifying the original.
- domain-specific languageA domain-specific language is a language designed for expressing solutions within a particular problem domain.
- delimited fileDelimited text data is structured textual data whose fields are separated by a specified delimiter character or sequence.
- choicesAn argparse choices option restricts an argument's value to a specified collection of allowed values.
- ordinal dataAn ordinal value is a representation that identifies the position of an item in an ordered sequence, such as first or second.
- re.matchre.match() is a Python re-module function that attempts to match a regular expression at the beginning of a string and returns a match object or None.
- exceptionAn exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
- characterAn individual textual element in a string, specifically an alphabetic symbol in this exercise.
- setA set is a collection that contains distinct elements without assigning significance to their order.
- empty stringAn empty string is a string value containing no characters.
- --seedA book-specific command-line option that specifies the seed controlling pseudo-random password generation.
- test_verse()A book-specific test function that checks the output or behavior of the verse() function for selected day numbers.
- logical AND operatorA logical AND operator is a Boolean conjunction that produces true exactly when all operands have true truth values.
- playerA player is a participant in the tic-tac-toe game identified by a marker such as X or O.
- random modulerandom is Python's standard-library module for generating pseudo-random values and performing random selections.
- translation tableA translation table is a mapping that specifies replacement values for characters processed by a string translation operation.
- pytestpytest is a Python testing framework that discovers and runs tests and reports their results.
- sys.exitsys.exit() is a Python function that terminates the current program and supplies an exit status or error message.
- exit codeAn error code is a numeric process exit status indicating that a program terminated because an error occurred.
- greedy matchingA regular-expression matching behavior in which a quantifier selects the longest possible substring that still permits the pattern to match.
- re.findall()re.findall() is a Python regular-expression function that returns all non-overlapping matches of a pattern in a string.
- enumerateenumerate() is a Python built-in function that produces pairs of indexes and values while iterating an iterable.
- concatenationConcatenation is the operation of combining values or ordered sequences into a single composite, typically preserving their order.
- extend methodlist.extend() is a Python list method that adds each element produced by an iterable to the end of the list.
- wc utilitywc is a Unix command-line utility that reports counts of bytes, characters, lines, and words in files or standard input.
- NoneNone is Python's singleton value representing the absence of a meaningful value.
- guardA guard is a conditional clause in a comprehension that determines which iterated elements are included in the resulting collection.
- help optionA help option is a command-line option that requests usage information and other program documentation.
- standard inputsys.stdin is the Python text stream object representing a process's standard input.
- headerA header is a record at the beginning of a tabular file that names or describes the fields in subsequent records.
- moduleA module is a distinct, bounded software unit that groups related code or functionality and provides an organizational or interaction boundary within a larger system.
- tabulatetabulate is a Python library for formatting iterable data as human-readable text tables.
- test-driven developmentTest-driven development is a software development practice in which tests are written before implementation and repeatedly run to guide development and detect regressions.
- articleAn indefinite article is a grammatical determiner, such as “a” or “an,” used with a nonspecific noun.
- rhyming wordA rhyming word is a word whose ending sound matches the ending sound of another word.
- re.compilere.compile() is a Python re function that compiles a regular-expression pattern into a reusable pattern object.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
