Book Image

Python for Finance

By : Yuxing Yan
Book Image

Python for Finance

By: Yuxing Yan

Overview of this book

Table of Contents (20 chapters)
Python for Finance
About the Author
About the Reviewers

Error messages

For the previous example, if we enter 100/(1+0.1)^2 instead of 100/(1+0.1), we will see the following error message, which tells us that ^ is not supported:

Traceback (most recent call last):
File "<psyhell#1>, line 1, in <module>
TypeError: unsupported operand type(s) for ^: 'float' and 'int'


Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

At this stage, a new user needs to pay attention to the last sentence of the error message. Obviously, the last line tells us that ^ is not supported. Again, for a power function, we should use double multiplications, **, instead of a karat, ^. In Chapter 2, Using Python as an Ordinary Calculator, we will show that a true power function, pow(), is available.