dict
Mathematical Programming with Python
https://people.sc.fsu.edu/~jburkardt/classes/...
python_2025/dict/dict.html
dict:
the Python dictionary data type is a very
clever and useful extension of the array. Instead of a numeric
index, a dictionary uses a keyword to find an item. It is easy
to add new entries to the dictionary. We will see that a
dictionary can be used to make our Collatz conjecture code
much more efficient, so that our data begins to resemble a
tree structure with each number pointing to its successor in
the sequence.
Lecture notes:
-
collatz_test.py,
uses a dict to keep track of which Collatz values have
already been calculated.
-
json_test.py,
reads a Collatz dict from a JSON file and updates it;
reads information from a JSON file and reports it.
-
states_test.py,
uses a dict to store pairs of state names and state capitals.
Last revised on 03 March 2025.