214|PYTHON&ChatGPT – Accounting Maestro ChatGPT

BYU Student Author: @Benjamin_Lau
Reviewers: @James_Gerstner, @Trent_Barlow
Estimated Time to Solve: 40 Minutes

We provide the solution to this challenge using:

  • ChatGPT
  • Excel
  • Python

Need a program? Click here.

Overview
Generative AI is becoming increasingly intelligent, transforming how we access and value knowledge. In the realm of education, this technology has made knowledge cheaper and more accessible than ever before. This challenge will demonstrate the power of generative AI, particularly its potential to revolutionize learning in fields such as accounting. You will be tasked with using ChatGPT to create an accounting dictionary. Following that, you will utilize Python to develop a platform that enables you and other users to interact with this dictionary data, thereby facilitating a novel way to learn accounting.

Instructions

  1. The data file gives you a list of accounting vocabulary and a blank “Explanation” column. Use ChatGPT to find out the explanations for these words. Copy and paste these explanations to the data file next to the word they describe. Try to prompt ChatGPT with phrases like “explain these as if you are explaining them to a 5-year-old child.” You can use different prompts according to your personal preference. Chat does better with small chunks: 10-20 terms.
  2. After generating the dictionary, close the Excel file and open a coding environment, like Visual Studio Code, Jupyter Notebook, etc. You will use Python to create an interactive platform to learn from this dictionary.
  3. Import pandas. Load in the data file as a pandas DataFrame. You can decide to keep the values as Pandas DataFrame or create a Python dictionary where the keys are the terms and the values are the explanations.
  4. Prompt the user to type in the accounting word he/she want to learn and store that in a variable. Make sure you make that case insensitive.
  5. If the word is in the dictionary, print out the explanation. After that, prompt user to answer if he/she wants to continue or not. If he/she wants to continue, repeat the process. If not, end the program.
  6. If the word is NOT in the dictionary, tell the user the word is not in the dictionary and ask if the user wants to quit or continue. If he/she wants to continue, repeat the process. If he/she wants to quit, end the program.

Data Files

Suggestions and Hints
  • If you prompt ChatGPT to return the results in a table format, you can just copy and paste the table to the data file.
  • Use input() to prompt the user.
  • When looking up the explanation for a word, consider using .query() and .iloc[0].

Solution

import pandas as pd

Load the updated dictionary file

file_path = “Updated_Accounting_Dictionary.xlsx” # Replace with the updated file path
df = pd.read_excel(file_path)

Convert to dictionary for easy lookup

accounting_dict = dict(zip(df[‘Term’].str.lower(), df[‘Explanation’]))

def interactive_learning():
print(“Welcome to the Accounting Dictionary! Type a term to learn about it.”)
while True:
# Ask the user for a term
user_input = input("\nEnter an accounting term: ").strip().lower()

    if user_input in accounting_dict:
        # If the term exists, display its explanation
        print(f"\nExplanation: {accounting_dict[user_input]}")
    else:
        # Inform the user if the term isn't in the dictionary
        print("\nThe term is not in the dictionary.")
    
    # Ask if the user wants to continue
    continue_choice = input("\nDo you want to look up another term? (yes/no): ").strip().lower()
    if continue_choice != 'yes':
        print("\nThank you for using the Accounting Dictionary! Goodbye!")
        break

Run the interactive learning program

interactive_learning()