A new data type – dictionary

Dictionaries are unordered datasets and are accessed via keys and not via their position. A dictionary is an associative array (also known as hashes). Any key of the dictionary is associated (or mapped) to a value. The first variable is the key, while the second one is the value; see the following example. The curly parentheses are used. The second value could be any data type such as a string, an integer, or a real number:

>>>houseHold={"father":"John","mother":"Mary","daughter":"Jane"}
>>> household
{'father': 'John', 'daughter': 'Jane','mother': 'Mary'}
>>> type(houseHold)
<class 'dict'>
>>>houseHold['father']
'John'

Appendix A – simple interest rate versus compounding interest rate

The formula for payment of a simple ...

Get Python for Finance - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.