Glossary

Accumulator

A variable that collects a result, such as a score, one step at a time: score = score + 1.

First taught in Unit 4

Append

items.append(value) adds a new item to the end of a list.

First taught in Unit 7

Arithmetic operators

The symbols +, -, *, /, //, and % calculate with numbers.

First taught in Unit 2

Attribute

A value stored on an object, reached with a dot, such as buddy.name.

First taught in Unit 10

Boolean

One of the two truth values, True or False.

First taught in Unit 2

Break

break leaves a loop at once, jumping to the first line after it.

First taught in Unit 4

Built-in function

A ready-to-use Python function such as len(), min(), or max().

First taught in Unit 7

Class

A set of instructions for making objects with the same kinds of attributes and methods.

First taught in Unit 10

Code comment

Words after # that explain code to a reader; Python does not run them.

First taught in Unit 1

Comparison

A test such as a < b or a == b that gives True or False.

First taught in Unit 2

Conditional inside a conditional

An if block placed inside another decision to ask a second question only on one path.

First taught in Unit 4

Count by condition

Add one to a count only when an item passes a test.

First taught in Unit 4

Counter variable

The variable that counts a loop's turns, such as side_number in for side_number in range(4):; it can do work inside the loop too.

First taught in Unit 3

Dictionary

A collection that connects each key to a value, written like {"cat": "gato"}.

First taught in Unit 8

Dictionary lookup and update

translations["cat"] gets the value for a key, and assigning to that place adds or changes it; .get(key, default) gives the default instead of an error when the key is missing.

First taught in Unit 8

Else and elif

Extra branches of an if decision: elif tests another condition, and else catches the remaining cases.

First taught in Unit 2

Error message

Python's clue about where and why a program stopped.

First taught in Unit 1

File reading

Getting saved text from a file with read() or a loop over its lines, after opening it without "w".

First taught in Unit 9

File writing

Saving text with write() after opening a file in "w" mode.

First taught in Unit 9

Filter into a list

Loop over items and append only the ones that pass a test to a new list.

First taught in Unit 7

Find the best

Keep the largest or smallest value seen so far, and sometimes the item that owns it.

First taught in Unit 7

Float

A Python number that can have a decimal part, such as 2.5; dividing with / always gives one.

First taught in Unit 3

For loop

A loop that visits each value from a range or collection in turn.

First taught in Unit 3

Formatted string

Text starting with f that puts a value inside braces, as in f"Score: {score}".

First taught in Unit 1

Function definition

A named group of instructions begun with def and run when you call it.

First taught in Unit 5

If statement

if runs an indented block only when its condition is true.

First taught in Unit 2

Import

import brings a module's tools into your program, as in import random.

First taught in Unit 2

Input

input() waits for someone to type a value and gives the program that value as text.

First taught in Unit 1

Integer

A whole number such as -2, 0, or 17; Python calls its type int.

First taught in Unit 2

List

An ordered collection of values written with square brackets, such as [4, 7].

First taught in Unit 7

List indexing

items[0] gets the first item and items[-1] the last.

First taught in Unit 7

Local scope

A name made inside a function is local and belongs there; a name made outside functions is global.

First taught in Unit 5

Logical operators

and, or, and not combine or reverse truth tests.

First taught in Unit 4

Loop over a dictionary

Visit its keys, or its key/value pairs with .items().

First taught in Unit 8

Loop over a list

for item in items: visits each list item in order.

First taught in Unit 7

Method

A function written inside a class and called through an object, such as buddy.play().

First taught in Unit 10

Name

A clear, meaningful word you choose for a variable or function so its job is easy to see.

First taught in Unit 1

Nested loops

A loop inside another loop; the inner loop completes its turns for each outer turn.

First taught in Unit 3

Object creation

__init__ runs when you make a new object and usually saves its first attributes through self.

First taught in Unit 10

Parameter

A blank in a function's definition, such as name in def greeting_card(name):; each call fills it with a value, in order.

First taught in Unit 5

Print

print() displays a value in the program's output.

First taught in Unit 1

Random numbers

random.randint(a, b) picks an integer from a through b; both ends can be picked.

First taught in Unit 2

Range

range(n) supplies the integers from 0 up to, but not including, n.

First taught in Unit 3

Return value

A result a function sends back with return.

First taught in Unit 5

Running a program

Asking Python to follow the instructions in a cell or a .py file.

First taught in Unit 1

Running total

Add each new number to a total as you visit it.

First taught in Unit 4

Scan until found

Check items one by one and stop as soon as the wanted item appears.

First taught in Unit 6

Sentinel loop

Keep repeating until a stop signal, such as a correct guess or a typed word, ends the loop.

First taught in Unit 2

Sort a list

items.sort() puts the items of that list in order, lowest first; items.sort(reverse=True) puts the highest first.

First taught in Unit 7

String

Text between quotes, such as "hello" or 'hello'.

First taught in Unit 1

String combining

+ joins strings into one longer string.

First taught in Unit 1

String index

A position in text; word[0] gets its first character and word[-1] its last.

First taught in Unit 6

String methods

Tools called on text that give a changed copy, such as .lower(), .upper(), .strip(), and .replace().

First taught in Unit 6

String slice

word[start:stop] takes characters from start up to, but not including, stop.

First taught in Unit 6

Test with in

"m" in letters asks whether one value appears inside another.

First taught in Unit 6

Transform each item

Visit every item and make a changed value for each one.

First taught in Unit 6

Turtle drawing

Pen commands such as turtle.color("blue"), turtle.pensize(4), turtle.penup(), and turtle.pendown() change the lines a turtle makes.

First taught in Unit 3

Turtle movement

Commands such as turtle.forward(100) and turtle.right(90) move and turn the drawing turtle.

First taught in Unit 3

Type conversion

int() turns digit-text into an integer, and str() turns a number into text.

First taught in Unit 2

Variable

A named place to keep a value, made with an assignment such as score = 3.

First taught in Unit 1

While loop

A loop that repeats its indented block while a condition is true.

First taught in Unit 2

With statement

with open(...) as f: gives a block a file and closes it when that block ends.

First taught in Unit 9