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

Assigning values to variables


To assign a value to a variable is simple because unlike many other languages such as C++ or FORTRAN, in Python, we don't need to define a variable before we assign a value to it.

>>>pv=22
>>>pv+2
24

We could assign the same value to different variables simultaneously. In the following example, we assign 100 to the three variables x, y, and z at once:

>>>x=y=z=100

Displaying the value of a variable

To find out the value of a variable, just type its name as shown in the following code:

>>>pv=100
>>>pv
100
>>>R=0.1
>>>R
0.1