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
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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:

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

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support 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.