Python Lesson 7 Python in Business Probability, Financial Fundamentals, and Data Analysis
Python Lesson 7 Python in Business Probability, Financial Fundamentals, and Data Analysis
import numpy as np
# Simulate rolling a die
print("Rolling a die once:",np.random.randint(1, 7))
# Roll a die 10 times
few_rolls = np.random.randint(1, 7, size=10)
print("Rolling a die 10 times:", few_rolls)
Coin Flips and Binomial Distribution
Binomial Distribution represents the number of successes in a
fixed number of trials. In business, it’s used in quality control
(e.g., defective items in a batch)
• Using the SciPy library to simulate coin flips as a binomial
distribution.
Future Value (FV) answers the question, “If I invest money now,
how much will it be worth in the future?”
investment = 1000
interest_rate = 0.1
years = 10
future_value = (1 + interest_rate) ** years * investment
print(f"Future Value after {years} years: ${future_value:.2f}")
Present Values
Present Value (PV) tells us the worth of future cash flows
today, aiding in investment decisions.
future_cash = 2593.74
years = 10
discount_rate = 0.05
present_value = future_cash / (1 + discount_rate)**years
print("Present Value:", present_value)
Three Dimensional Graphs
• 3D Graphing: 3D graphs allow visualization across multiple
variables. In business, we can plot factors like sales volume
vs. product type vs. customer segment.
• Use Matplotlib's 3D plotting features to visualize relationships
between multiple variable