Week 3: Control Flow: Conditional Statements and Loops

Learn how to make decisions and repeat tasks in Python, essential for financial analysis and automated trading strategies.

Learning Objectives:

Exercises:

  1. Write a program that:
    • Takes a stock price as input
    • If price > 100, print "High-priced stock"
    • If 50 ≤ price ≤ 100, print "Medium-priced stock"
    • If price < 50, print "Low-priced stock"
  2. Create a program that calculates compound interest over multiple years using a loop
  3. Write a program that analyzes a list of stock prices and:
    • Finds the highest and lowest prices
    • Calculates the average price
    • Counts how many days the price was above average
  4. Create a simple trading simulator that:
    • Loops through daily prices
    • Uses if statements to make buy/sell decisions
    • Tracks portfolio value
  5. Write a program that calculates the total return of an investment with monthly contributions over a period of years
  6. Create a loan payment calculator that shows the remaining balance after each payment using a loop

💡 ChatGPT Learning Tips

Use these prompts to enhance your learning:

  1. "Show me how to use if-else statements to create a basic stock trading decision system"
  2. "Explain how to use a for loop to calculate compound interest over multiple years"
  3. "Help me create a flowchart for a simple trading strategy using Python"
  4. "What are common patterns in financial calculations that use loops?"
← Previous Week | Next Week →
← Back to Home