My portfolio has 4 stocks: ['AAPL', 'GOOG', 'TSLA', 'NVDA']
Introduction to Business Analytics — HKUST
The language of data
“Coding is not just for tech people — it is for anyone who wants to run a competitive company in the 21st century.” — Mary Callahan Erdoes, JPMorgan
A list stores an ordered collection of items.
My portfolio has 4 stocks: ['AAPL', 'GOOG', 'TSLA', 'NVDA']
Why it matters
In business, lists represent portfolios, customer IDs, survey responses, product catalogs.
Python counts from 0. Negative indices count from the end.
First : AAPL
Last : NVDA
Middle: ['GOOG', 'TSLA']
Business problem: Apply a 10% price increase to all products.
[110.00000000000001, 275.0, 88.0, 352.0, 192.50000000000003]
Filter premium products (price > 150):
[250, 320, 175]
Conditional: Generate Buy/Sell signals:
['BUY', 'SELL', 'BUY', 'SELL', 'SELL', 'BUY', 'SELL']
0 100
1 102
2 98
3 105
4 101
Name: AAPL, dtype: int64
Mean : 101.20
Std : 2.59
Max : 105
Array * 2: [200 204 196 210 202]
Array + 10: [110 112 108 115 111]
Important
A plain Python list multiplied by 2 repeats the list. A NumPy array multiplied by 2 doubles each element.
Mean : 0.0549
Std : 0.1849
Min : -0.2919
Max : 0.4705

P(X < 10) = 0.8413
5th percentile: x = 4.7103
Wealth \(X \sim \mathcal{N}(\mu=\$1M, \sigma=\$500K)\). Find the 5% VaR.
95% VaR: $177,573
Loss if worst 5%: $822,427
Today you learned
Next time: DataFrames — the spreadsheet of Python. See Topic 2 →