
Python for Finance
By :

There are three ways to launch Python and they are explained in the following sections.
To launch Python, perform the following steps:
Assume that an estimate of $100 is expected to be received in one year with an annual discount rate of 10 percent. The present value of one future cash flow is as follows:
In this equation, PV is the present value, FV is the future value, R is the discount rate, and n is the number of periods. According to the preceding formula, we could manually type those values to get the present value of this one future cash flow. Assume that we would receive $100 in one year. If the annual discount rate is 10 percent, what is the present value of this $100? For this, let's take a look at the following lines of code:
>>>100/(1+0.1) 90.9090909090909 >>>
The triple larger than signs (>>>
) is the Python prompt.
It is a good idea to create a Python icon on your desktops for your convenience. In addition to the preceding method, there are other methods to launch Python; see the next two sections: Launching Python from the Python command line and Launching Python from our own DOS window.
A new user could skip this section and go to the Quitting Python section because learning how to launch Python with GUI is more than enough. There are two reasons for this. The first is because we know how to launch Python by using Python IDLE or by clicking on the Python icon on our desktops, and the second reason is that we could save and run our Python programs easily using Python IDLE.
To launch Python from the Python command line, we have to perform the following steps:
We could generate our own DOS window, and then launch Python from there. In addition, we could navigate to the subdirectory, which contains our Python programs. In order to this, perform the following steps:
cmd
in the run window as shown in the following screenshot:cd c:\python33
to move to the appropriate directory.python
to run the software as shown in the following screenshot:If we want to launch Python anywhere else, we have to include the path of our Python directory. Assume that after installation we have python33
in C:
. Replace step 2 with the following DOS command:
set path=%path%;C:\python33
Change the font size
Change margin width
Change background colour