Python flash cards: Apprentice level
107 Python terms at the Apprentice level, as flash cards.
Updated
Terms in this deck
- **kwargs
- Lets a function accept any number of keyword arguments, collected as a dictionary.
- *args
- Lets a function accept any number of positional arguments, collected as a tuple.
- append()
- Adds one item to the end of a list.
- Argument
- The actual value you hand to a function when you call it.
- AssertionError
- The error Python raises when an assert's condition is False; it carries the assert's message.
- Bin
- One range of values in a histogram, such as $5 to $10; its bar's height is how many values fall in it.
- break
- Stops a loop immediately.
- Breakpoint
- A mark on a line, the red dot in VS Code's margin, that pauses a program under the debugger before that line runs.
- Causation
- One thing making another happen. Showing it takes more than two things moving together, usually a test that changes one thing at a time.
- Command-Line Argument
- A word typed after a Python script's name when it's started, which the script reads from sys.argv or with argparse.
- continue
- Skips to the next pass of the loop.
- Data Analysis
- Answering questions with numbers from a table of data, such as which store sold the most last month.
- Debugger
- A tool, such as the one in VS Code's Python extension, that pauses a running program so you can step through it and look at its variables.
- def
- The keyword that starts a function definition: def, the function's name, parentheses and a colon, read "define".
- Default Parameter Value
- A value a parameter uses when the caller leaves that argument out.
- Dictionary
- Stores values under keys so you can look them up by name.
- Docstring
- A triple-quoted note under a function line that explains what it does.
- DPI
- Dots per inch: how many pixels each inch of a saved picture becomes, so 10 inches at 150 dpi is 1500 pixels wide.
- Duplicate Row
- A row that repeats an earlier one, in every column or in the columns that make two rows the same event.
- enumerate()
- Gives each item in a loop along with its position number.
- Execution Count
- The number beside a notebook cell, such as [4]: this was the fourth cell run since the kernel started.
- File Mode
- Tells open() what you plan to do: "r" read, "w" write, "a" add to the end.
- FileNotFoundError
- The error Python stops with when it's asked to read a file that isn't there, most often because the name is misspelled or the terminal is in another folder.
- fit()
- The scikit-learn method that trains a model on examples: model.fit(X, y) learns from the features X and the labels y.
- for Loop
- Repeats code once for each item in a collection.
- from … import
- Brings in just the names you want from a module.
- Function
- A named block of code, written once with def and run whenever a line calls its name with parentheses.
- Global Variable
- A variable created outside any function, readable anywhere in the file.
- head()
- A pandas method that shows a DataFrame's first rows, five unless you ask for another number; tail() shows the last.
- Histogram
- A chart of touching bars that counts how many values fall in each range, to show how one column's values are spread.
- Immutable
- Can't be changed after it is created, like a string or tuple.
- import
- Brings a module into your file so you can use it.
- Infinite Loop
- A loop that never stops because its condition never becomes false.
- info()
- A pandas method that lists every column of a DataFrame with its dtype and how many values are there, which shows the gaps.
- isna()
- A pandas method that answers True for each missing value and False for the rest; isna().sum() counts them.
- items()
- A dictionary method that gives each key with its value, one pair at a time, so a loop can name both halves.
- join()
- Glues a list of strings into one string with a separator between them.
- Kernel
- The Python program that runs a notebook's cells and remembers every name they make, in the order they ran.
- KeyError
- The error Python raises when a dictionary is asked for a key it doesn't have; its message names the missing key.
- Key-Value Pair
- One entry in a dictionary: a key and the value stored under it.
- Keyword Argument
- An argument passed by naming the parameter, like size="large".
- Legend
- A chart's small key that names each line or set of bars beside a sample of it; matplotlib draws it with ax.legend(), needed only when there's more than one.
- List
- An ordered collection in square brackets that you can add to and change.
- List Index
- An item's position in a list, counting from 0.
- Local Variable
- A variable created inside a function; it only exists inside that function.
- Long Format
- A table with one row for each value and one column for each kind of value, such as student, quiz and score: simple to filter and group.
- Marker
- The small shape a line chart draws at each point, such as a circle or a square, which tells lines apart without color.
- math Module
- A standard module with square roots, pi and other math tools.
- Membership Operator (in)
- in checks whether a value is inside a collection.
- min() and max()
- Give the smallest and largest value.
- Misleading Chart
- A chart that leaves the reader believing something false, often with every number right, through its axis, scale or colors.
- Module
- A Python file whose code you can use in another file.
- ModuleNotFoundError
- The error Python gives when an import names a package the Python running the code doesn't have installed.
- Mutable
- Can be changed after it is created, like a list or dictionary.
- NaN
- Read "not a number": pandas' mark for a missing value in a table.
- Negative Index
- An index that counts from the end: -1 is the last item.
- Nested List
- A list inside another list, like rows and columns.
- Nested Loop
- A loop inside another loop.
- nunique()
- A pandas method that counts how many different values a column holds.
- open()
- Opens a file so you can read from it or write to it.
- Outlier
- A real reading far from the usual ones, such as a storm's strongest gust; unlike a mistake, it's true, so it stays in the data.
- Parameter
- A name in a function definition for a value the function needs.
- pass
- Does nothing. A placeholder where Python needs at least one line.
- Percentile
- The value a given share of the data sits at or below: 90% of the rents are at or under the 90th percentile.
- Pivot Table
- A summary laid out as a grid: one column's values down the side, another's across the top, and a total, count or average in every square.
- pop()
- Removes an item from a list and hands it back (the last one by default).
- Positional Argument
- An argument matched to a parameter by its position in the call.
- predict()
- The scikit-learn method that uses a fitted model to guess the label for each row of new features: model.predict(X).
- PyPI
- The Python Package Index at pypi.org, the public library of packages that pip downloads and installs from.
- random Module
- A standard module for random numbers and picks.
- range()
- Makes a series of numbers, usually to repeat something a set number of times.
- read()
- Reads a whole open file into one string.
- read_csv()
- pd.read_csv loads a CSV file into a DataFrame; usecols, nrows and sep choose the columns, the rows and the separator.
- Recursion
- A function calling itself to solve a smaller piece of the same problem.
- Restart and Run All
- Stopping a notebook's kernel, then running every cell once from top to bottom, so the results are the ones the file really gives.
- Return Value
- The result a function hands back with return.
- Sample Size
- How many observations a number rests on, such as the 18 sessions behind a rate; the smaller it is, the further a few rows can move the number.
- savefig()
- A matplotlib Figure method that saves the whole chart, or page of charts, as an image file such as a PNG or SVG; the file's ending picks the format.
- Scatter Plot
- A chart with one dot for each row, one number across and one up, that shows whether the two numbers move together.
- scikit-learn
- The Python package for machine learning: ready-made models, tools to split and prepare data, and scores; installed as scikit-learn, imported as sklearn.
- Scope
- Where in the code a variable can be used.
- Set
- A collection with no duplicates and no set order.
- Short-Circuit Evaluation
- Python stops checking an and/or as soon as it knows the answer.
- Slicing
- Taking a piece of a list or string with [start:stop].
- sort()
- Puts a list in order, changing the list itself.
- sort_values()
- A pandas method that puts a table's rows in order by one column or several, with ascending= for each one's direction.
- sorted()
- Gives back a new sorted list and leaves the original alone.
- split()
- Breaks a string into a list of pieces.
- Standard Library
- The modules that come with Python, ready to import.
- strip()
- Removes spaces from both ends of a string.
- sum()
- Adds up all the numbers in a list.
- Tick Label
- One of the small labels along a chart's axis, such as a date or a number, that marks a place on the scale.
- Time Series
- Values recorded over time, one for each date or moment, such as daily sales or hourly temperatures.
- to_csv()
- A pandas method that saves a table as a CSV file; index=False leaves the row labels out.
- train_test_split()
- scikit-learn's function that shuffles rows and splits them into a training part and a test part; test_size sets the share held back.
- Truncated Axis
- A chart axis that starts above zero; on a bar chart it makes small differences look large.
- Tuple
- A list that can't be changed once made, written with round brackets.
- Tuple Unpacking
- Putting each item of a tuple into its own variable in one line.
- unique()
- A pandas method that lists each different value in a column once, in the order it first appears.
- upper() and lower()
- Give an all-caps or all-lowercase copy of a string.
- value_counts()
- A pandas method that counts how many rows hold each value of a column, most common first; normalize=True gives shares instead.
- ValueError
- The exception Python raises for a value of the right type that can't be used, such as float("two").
- while Loop
- Keeps repeating as long as its condition stays true.
- Wide Format
- A table that spreads one kind of value across many columns, such as a column for each quiz: quick for people to read.
- with Statement
- Opens something, like a file, and closes it for you when the block ends.
- write()
- Puts text into an open file.
- zip()
- Pairs up items from two or more lists so you can loop through them together.