🔸 Code Along for F-IE-3: User Survey DataDive

Task 1: Engage with AI Coding Assistants

As part of your involvement in the survey on AI coding assistants, it’s essential to first-hand experience the tools you’re evaluating. For this initial task, engage with GitHub Copilot or another AI coding assistant. After experimenting, please share your insights by replying to this post with 2-3 potential survey questions that would be relevant based on your experience. Additionally, participate in discussions by responding to suggestions from your peers. This engagement is not only a chance to ignite a lively discussion but also to deepen your understanding of AI coding assistants and kickstart your internship dynamically.

Note: Completing Tasks 1 & 2 and actively participating in the discussion qualifies as an alternative to the AI Evaluator stage. Alternatively, if you prefer a more structured evaluation, you may opt to participate in the AI Evaluator session, where your understanding and insights of the User Survey Project will be assessed.

Demo with GitHub Copilot: Building Currency Converters

We’ll create a currency converter with predefined rates and add exercises to extend its functionality. This will demonstrate how GitHub Copilot can assist with different aspects of coding tasks.

Tips for using GitHub Copilot effectively:

  1. Start with comments: Write descriptive comments about what you want to achieve, and let Copilot suggest the implementation.

  2. Use natural language prompts: If you’re unsure about syntax, type your intent in natural language, and Copilot will often suggest the correct code.

  3. Iterate on suggestions: If Copilot’s first suggestion isn’t quite right, keep typing or modify the suggestion to guide it towards what you need.

  4. Learn from suggestions: Pay attention to the code Copilot suggests, as it can teach you new patterns or best practices.

  5. Verify and understand the code: Always review and understand the code Copilot suggests before using it, especially for critical functionality.

  6. Use Copilot for repetitive tasks: Let Copilot handle boilerplate code or repetitive structures, saving you time and reducing errors.

  7. Combine with documentation: When using new libraries or functions, refer to official documentation alongside Copilot’s suggestions for the best results.

1. Set Up Your Environment

Click here for details
  1. Install Python:
  • Go to Download Python | Python.org
  • Download the latest version for your operating system
  • Run the installer, making sure to check “Add Python to PATH”
  1. Install Visual Studio Code:
  1. Set up Python in VS Code:
  • Open VS Code
  • Go to Extensions (Ctrl+Shift+X)
  • Search for “Python” and install the official Python extension
  1. Install required packages:
  • Open a terminal in VS Code (View > Terminal)
  • Run: pip install numpy pandas matplotlib scikit-learn
  1. Install GitHub Copilot:
  • In VS Code, go to Extensions again
  • Search for “GitHub Copilot” and install it
  • Follow the prompts to sign in to your GitHub account

2. Create the Converter Script

# currency_converter.py

# Define a dictionary of exchange rates (you can expand this)
exchange_rates = {
    'USD': 1.0,
    'EUR': 0.85,
    'GBP': 0.73,
    'JPY': 110.62,
    'CAD': 1.25
}

def convert_currency(amount, from_currency, to_currency):
    # Check if both currencies are in our exchange_rates dictionary
    if from_currency not in exchange_rates or to_currency not in exchange_rates:
        return None
    
    # Convert to USD first (if not already in USD)
    usd_amount = amount / exchange_rates[from_currency]
    
    # Then convert from USD to the target currency
    converted_amount = usd_amount * exchange_rates[to_currency]
    
    # Round to 2 decimal places for cents
    return round(converted_amount, 2)

def display_currencies():
    print("Available currencies:", ", ".join(exchange_rates.keys()))

def get_user_input():
    from_currency = input("Enter the currency you're converting from: ").upper()
    to_currency = input("Enter the currency you're converting to: ").upper()
    amount = float(input("Enter the amount: "))
    return from_currency, to_currency, amount

def main():
    print("Welcome to the Currency Converter!")
    
    while True:
        display_currencies()
        from_currency, to_currency, amount = get_user_input()
        
        result = convert_currency(amount, from_currency, to_currency)
        
        if result is not None:
            print(f"{amount} {from_currency} is equal to {result} {to_currency}")
        else:
            print("Invalid currency. Please choose from the available currencies.")
        
        if input("Do you want to perform another conversion? (yes/no): ").lower() != 'yes':
            break

    print("Thank you for using the Currency Converter!")

# Exercise 1: Complete the function
# Use Copilot to help you complete this function that adds a new currency to the exchange_rates dictionary
def add_new_currency(currency_code, rate):
    # Your code here (let Copilot suggest the implementation)
    pass

# Exercise 2: Complete the function
# Use Copilot to help you complete this function that removes a currency from the exchange_rates dictionary
def remove_currency(currency_code):
    # Your code here (let Copilot suggest the implementation)
    pass

# Exercise 3: Define and implement the function
# Use Copilot to help you create a function that finds the currency with the highest and lowest exchange rate
# Hint: Start by writing a comment describing what you want the function to do

# Exercise 4: Define and implement the function
# Create a function that converts an amount from one currency to all other available currencies
# and displays the results sorted from highest to lowest converted amount
# Hint: Start by writing a comment describing what you want the function to do

if __name__ == "__main__":
    main()

# After implementing the exercise functions, try calling them in the main() function
# to extend the functionality of your currency converter!

3. Run and Test Your Application

  • Execute your script in the terminal to see it in action.




Task 2: Analysis of Consumer Price Index Trends Using ChatGPT

After exploring the capabilities of AI coding assistants, it’s time to delve into more complex data analysis. In this task, you’ll use ChatGPT to analyze the Consumer Price Index (CPI) data to uncover insights into inflation trends, seasonal variations, and make predictions about future economic conditions. Please share your insights by replying to this post with 2-3 possible ways you may use chatGPT or equivalent to do data analysis on the data you will collect. Students comfortable with these two tasks are ready to start working with their teams!

Specific Dataset

  • Dataset: Consumer Price Index (CPI) from the U.S. Bureau of Labor Statistics.
  • Data Characteristics: Monthly CPI data from the past 10 years (2013-2023), available in CSV format.
  • Access Link: BLS CPI Data
  • Specific File to Download: Navigate to “CPI-All Urban Consumers (Current Series)” and download “U.S. city average, All items - CUUR0000SA0”

Steps to Implement the Project

  1. Data Loading:

    • Download the CPI dataset CSV file from the BLS website as instructed above.
    • Open the CSV file and familiarize yourself with its structure. You should see columns for Year, Period (month), and CPI value.
    • Prepare a simplified version of this data in a format easy to share with ChatGPT, for example:
      Year, Month, CPI
      2013, Jan, 229.601
      2013, Feb, 232.166
      ...
      2023, Dec, 305.106
      
  2. Calculate Inflation Rates:

    • Use the following prompt with ChatGPT: “I have monthly CPI data from 2013 to 2023. Can you help me calculate the year-over-year inflation rate for each year? Here’s a sample of my data: [Paste your simplified data here] Please show me how to calculate it and provide the results.”
  3. Identify Seasonal Variations:

    • Use this prompt: “Using the CPI data I provided earlier, can you identify any seasonal trends? Focus on comparing the same months across different years. Are there any patterns in how CPI changes throughout the year?”
  4. Forecast Future CPI Changes:

    • Provide ChatGPT with the most recent 5 years of data (2019-2023) and use this prompt: “Based on this 5-year CPI data, can you predict the CPI values for each month of 2024? Please explain your method and any assumptions you’re making.”
  5. Analyze Impact by Category:

    • For this step, you’ll need category-specific data. Download additional datasets for categories like Food, Energy, Housing, etc. from the same BLS page.
    • Provide ChatGPT with a summary of changes in these categories and ask: “I have the following average annual changes for different CPI categories over the past 5 years: [List your category data here] Can you rank these categories by volatility and explain what these changes might mean for consumers and businesses?”
  6. Correlation Analysis:

    • Obtain unemployment rate data from the BLS website (https://www.bls.gov/charts/employment-situation/civilian-unemployment-rate.htm)
    • Provide both CPI and unemployment data to ChatGPT and ask: “Here’s the annual CPI data and unemployment rates for the past 10 years. Can you analyze if there’s any correlation between these two indicators? What might explain any relationship or lack thereof?”
  7. Summarize Findings:

    • After completing the above analyses, use this prompt: “Based on all the analyses we’ve done on the CPI data, including inflation rates, seasonal trends, forecasts, category impacts, and correlation with unemployment, can you provide a comprehensive summary of the key insights? Please include potential economic implications of these findings.”