Compound Interest exchange_rates = {
**Formula**: "CAD": {"USD": 1.3118, "EUR": 1.4983},
FV = P × (1 + r/n)^(n×t) "USD": {"CAD": 0.7625, "EUR": 1.1417}
Where: }
- FV = Future Value
- P = Principal def convert(amount, from_curr, to_curr):
- r = Annual interest rate (decimal) return amount * exchange_rates[from_curr][to_curr]
- n = Compounding periods per year ```
- t = Time in years
Linear Systems (Algebraic Solutions)
**Examples**: **Example**:
- $2,000 at 8% semi-annually for 10 years: 2x + 3y = 12
FV = 2000 × (1 + 0.08/2)^(2×10) = $4,317.85 4x - y = 5
- Same investment compounded monthly:
FV = 2000 × (1 + 0.08/12)^(12×10) = $4,440.21 **Solution**:
From second equation: y = 4x - 5
**Present Value**: Substitute into first: 2x + 3(4x - 5) = 12 → x = 1.5
PV = FV / (1 + r/n)^(n×t) Then y = 4(1.5) - 5 = 1
- $50,000 in 20 years at 5% quarterly:
PV = 50000 / (1 + 0.05/4)^(4×20) = $18,424.35 Key Takeaways
1. **Compound interest** grows faster with more frequent
Simple Interest compounding
**Formula**: 2. **Trade discounts** reduce purchase price while **cash
I=P×r×t discounts** encourage early payment
FV = P × (1 + r × t) 3. **Markup** is based on cost, **margin** is based on selling price
4. **Break-even** analysis helps determine minimum sales needed
**Examples**: 5. Always verify currency conversion rates are up-to-date
- $5,000 at 4% for 3 years: 6. For loans, longer terms mean more total interest paid
I = 5000 × 0.04 × 3 = $600
FV = $5,600 Break-Even Analysis (`[Link]`)
- $10,000 loan at 6% for 5 years:
Total repayment = 10000 × (1 + 0.06 × 5) = $13,000 Key Functions:
Trade Discounts def calculate_break_even(fixed_costs, variable_cost, selling_price):
**Formula**: if selling_price <= variable_cost:
Discount Amount = List Price × Discount Rate print("Error: Selling price must be greater than variable cost.")
Discounted Price = List Price - Discount Amount return None, None
be_units = fixed_costs / (selling_price - variable_cost)
**Example**: be_revenue = be_units * selling_price
$500 product with 20% trade discount: return be_units, be_revenue
$500 × 0.20 = $100 discount → $400 final price
Usage Example:
Cash Discounts
**Formula**: fixed = 10000 # Fixed costs
Discount Amount = Invoice Amount × Discount Rate variable = 5 # Cost per unit
Effective Annual Rate = [(Discount/(1-Discount)) × (365/(Full Period- price = 15 # Selling price per unit
Discount Period))] × 100 units, revenue = calculate_break_even(fixed, variable, price)
print(f"Break-even at {units:.2f} units (${revenue:.2f} revenue)")
**Example**: "2/10, net 30" on $12,000 invoice:
- Discount = $12,000 × 0.02 = $240 Visualization:
- EAR = [(0.02/0.98) × (365/20)] × 100 = 37.24%
def plot_graph(fixed_costs, variable_cost, selling_price,
Markup and Markdown break_even_units):
**Markup Formula**: units = [Link](0, max_units + 1, 10)
Selling Price = Cost × (1 + Markup %) total_costs = fixed_costs + variable_cost * units
Profit Margin = (Selling Price - Cost)/Selling Price × 100 revenues = selling_price * units
**Example**: $40 jacket with 75% markup: [Link](units, total_costs, label="Total Cost")
$40 × 1.75 = $70 selling price [Link](units, revenues, label="Revenue")
Margin = (70-40)/70 × 100 = 42.86% [Link](x=break_even_units, color='red', linestyle='--')
[Link]()
**Markdown Formula**:
New Price = Original × (1 - Markdown %) Currency Converter (`[Link]`)
**Example**: $120 jacket with 20% then 10% markdown: Core Function:
First markdown: $120 × 0.80 = $96
Second markdown: $96 × 0.90 = $86.40 exchange_rates = {
"USD": {"EUR": 0.85, "GBP": 0.75},
Break-Even Analysis "EUR": {"USD": 1.18, "GBP": 0.88}
**Formula**: }
Break-Even Units = Fixed Costs / (Selling Price - Variable Cost)
def currency_conversion(amount, from_currency, to_currency):
**Example**: if from_currency in exchange_rates and to_currency in
Fixed costs = $10,000, variable cost = $5/unit, selling price = exchange_rates[from_currency]:
$15/unit: return amount * exchange_rates[from_currency][to_currency]
BE Units = 10,000 / (15-5) = 1,000 units return None
```
Currency Conversion (Python)
Menu-Driven Example:
return value
def main(): print("Must be non-negative")
conversions = { except ValueError:
"1": ("USD", "EUR"), print("Invalid number")
"2": ("EUR", "GBP")
} Visualization:
while True: def visualize_results(results, metric_type, vary_by):
print("1. USD to EUR\n2. EUR to GBP\n3. Exit") x = [val for val, _ in results]
choice = input("Select: ") y = [res for _, res in results]
if choice == "3": [Link](x, y, marker='o')
break [Link](f"{metric_type} by {vary_by}")
elif choice in conversions: [Link](vary_by)
from_curr, to_curr = conversions[choice] [Link](metric_type)
amount = float(input(f"Amount in {from_curr}: ")) [Link]()
result = currency_conversion(amount, from_curr, to_curr) [Link]()
print(f"{amount} {from_curr} = {result:.2f} {to_curr}")
Trade Discount Calculator:
Financial Calculations (`[Link]`)
def calculate_trade_discount(list_price, discount_rate):
Core Formulas: discount = list_price * discount_rate
return list_price - discount
# Simple Interest
def calculate_simple_interest(principal, rate, time): Common Patterns
return principal * rate * time
1. **Menu Systems**:
# Future Value (Simple Interest)
def calculate_future_value(principal, rate, time): while True:
return principal * (1 + rate * time) print("1. Option 1\n2. Option 2\n3. Exit")
choice = input("Select: ")
# Present Value if choice == "1":
def calculate_present_value(future_value, rate, time): # Handle option 1
return future_value / (1 + rate * time) elif choice == "3":
break
CSV Processing:
2. **Financial Rounding**:
def process_bulk_file(filename):
with open(filename, 'r') as file: rounded_value = round(result, 2) # For currency
reader = [Link](file)
for row in reader:
principal = float(row['Principal']) 3. **Error Handling**:
rate = float(row['Rate'])/100
time = float(row['Time'])
try:
si = calculate_simple_interest(principal, rate, time) value = float(input("Enter amount: "))
fv = calculate_future_value(principal, rate, time) except ValueError:
pv = calculate_present_value(fv, rate, time) print("Invalid number format")
```
print(f"Principal: ${principal:.2f} | Rate: {rate*100:.2f}%")
print(f"Future Value: ${fv:.2f}") 4. **Bulk Processing**:
Comparison Tool: with open('[Link]') as f:
reader = [Link](f)
def compare_metrics(principal, rate, time, metric_type, vary_by, for row in reader:
values): process_row(row)
results = []
for value in values: Remember to:
r = float(value) if vary_by == 'rate' else rate - Always validate financial inputs
t = float(value) if vary_by == 'time' else time - Use proper rounding for currency values
- Include clear docstrings for financial functions
if metric_type == 'SI': - Test edge cases (zero values, negative numbers where prohibited)
result = calculate_simple_interest(principal, r, t)
elif metric_type == 'FV':
result = calculate_future_value(principal, r, t)
elif metric_type == 'PV':
result = calculate_present_value(fv, r, t)
[Link]((value, result))
return results
Python Tips for Financial Calculations
Input Validation:
def get_float_input(prompt):
while True:
try:
value = float(input(prompt))
if value >= 0: