Introduction to Python for Finance
Adina Howe
Associate Professor
Store information that can be referenced in code
msft_stock
, interest_rate
, bonds
interest_rate = 0.05
Variable names
class
or type
) and should be avoided# Correct
day_2 = 5
# Incorrect, variable name starts with a digit
2_day = 5
$$ \text{Price to earning ratio} = \frac{\text{Market price}}{\text{Earnings per share}} $$
price = 200 earnings = 5
pe_ratio = price / earnings
print(pe_ratio)
40
Introduction to Python for Finance