# 214|PYTHON&CHATGPT – Accounting Maestro ChatGPT

**URL:** <https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698>\
**Category:** Challenges\
**Tags:** beginner, python, pandas, chatgpt, accounting\
**Created:** [May 14, 2024, 6:55pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698 "2024-05-14T18:55:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Lau](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/benjamin_lau/32/379_2.png) [@Benjamin\_Lau](https://www.techhub.training/u/Benjamin_Lau)\
**Post date:** [May 14, 2024, 6:55pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/1 "2024-05-14T18:55:49Z")

</div>

_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](https://www.techhub.training/t/information-about-software-used-on-techhub-training/138).

**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**

- [Challenge214\_Accounting Maestro - ChatGPT.xlsx](https://byu.box.com/shared/static/mcyo1s5gb61u9tx3e9s4bv2sm8jew6nc)

> **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**

[Challenge214\_Accounting Maestro ChatGPT\_Solution.xlsx](https://byu.box.com/shared/static/twzdza25n8fgnrlisql8valjuqgtuzhs)  
[Challenge214\_Accounting Maestro ChatGPT\_Solution.txt](https://byu.box.com/shared/static/j7h8wltedzsyd48noccz36pu9po6i0se)  
_Solution Video:_ [Challenge 214PYTHON&ChatGPT – Accounting Maestro ChatGPT](https://youtu.be/PbZGY4xMBEI)

---

<div class="post-metadata">

**Author:** ![Gabe\_Esplin](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/gabe_esplin/32/6968_2.png) [@Gabe\_Esplin](https://www.techhub.training/u/Gabe_Esplin)\
**Post date:** [December 9, 2024, 4:12am UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/2 "2024-12-09T04:12:45Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![James\_Behling](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/james_behling/32/7299_2.png) [@James\_Behling](https://www.techhub.training/u/James_Behling)\
**Post date:** [January 24, 2025, 10:14pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/3 "2025-01-24T22:14:05Z")

</div>

Time to complete: 1 hour  
Rating: Intermediate  
Comments: I really enjoyed this case, I had some errors that I had to deal with relating to my laptop, and ChatGPT was very excellent at helping me to reconfigure my laptop so that I could complete this challenge. After dealing with those challenges, ChatGPT excelled at writing the code for my python file, I only had to iterate twice to get it functioning completely. Below is my solution:

import pandas as pd

# Load the data file into a pandas DataFrame

file\_path = “Challenge214\_Accounting\_Maestro.xlsx” # Update with the actual file name if different  
data = pd.read\_excel(file\_path)

# Create a dictionary where keys are terms and values are explanations

dictionary = dict(zip(data[‘Term’].str.lower(), data[‘Explanation’]))

# Interactive platform

def learn\_accounting\_terms():  
print(“Welcome to the Accounting Dictionary Interactive Platform!\n”)  
while True:  
# Prompt the user to input a term  
term = input("Type an accounting word you want to learn: ").strip().lower()

```
    # Check if the term is in the dictionary
    if term in dictionary:
        print(f"\nExplanation for '{term}': {dictionary[term]}\n")
    else:
        print(f"\nSorry, the word '{term}' is not in the dictionary.\n")

    # Ask if the user wants to continue
    continue_prompt = input("Do you want to continue? (yes/no): ").strip().lower()
    if continue_prompt not in ['yes', 'y']:
        print("\nThank you for using the Accounting Dictionary Interactive Platform! Goodbye!")
        break

```

# Run the interactive platform

learn\_accounting\_terms()

---

<div class="post-metadata">

**Author:** ![Kaden\_Sandberg](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/kaden_sandberg/32/7296_2.png) [@Kaden\_Sandberg](https://www.techhub.training/u/Kaden_Sandberg)\
**Post date:** [January 25, 2025, 1:18am UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/4 "2025-01-25T01:18:27Z")

</div>

Time: 1 hour  
Rating: Intermediate  
Comments: I really enjoyed this challenge since it involved both using chatGPT to help me define the accounting terms in goofy ways and to help me code quicker. I still ended up taking an hour because I redid the first half of my terms to use a dinosaur theme in my explanations and I also tried to code on my own.

```import
df = pd.read_excel("\Challenge214_Accounting Maestro ChatGPT.xlsx",sheet_name=0) # to update with own filepath
df.head()

def get_definition(word):
    """Finds the definition of the word/phrase in a case-insensitive way."""
    word = word.lower() # Normalize input (remove spaces and make lowercase)
    match = df[df["Term"].str.lower() == word] # Case-insensitive match
    
    if not match.empty:
        return match.iloc[0]["Explanation"]
    else:
        return None

def ask_to_continue():
    """Asks the user whether they want to continue or quit."""
    while True:
        user_input = input("Do you want to continue? (yes/no): ").lower()
        if user_input in ["yes", "y"]:
            return True
        elif user_input in ["no", "n"]:
            return False
        else:
            print("Invalid input! Please type 'yes' or 'no'.")

def play_game():
    """Runs the word definition lookup game with multi-word term support."""
    print("🦕 Welcome to the Dino Dictionary Game! 🦖")
    print("Type a word or phrase to get its definition.\n")

    while True:
        user_input = input("Enter a word or phrase: ")
        definition = get_definition(user_input)
        
        if definition:
            print(f"📖 Definition: {definition}\n")
        else:
            print("Sorry, that word/phrase is not in our dino-dictionary! 🦖")
        
        if not ask_to_continue():
            print("Goodbye! Keep learning about dinosaurs and finance! 🦕")
            break

# Start the game
play_game()

```

---

<div class="post-metadata">

**Author:** ![Keanu\_Gauthier](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/keanu_gauthier/32/7304_2.png) [@Keanu\_Gauthier](https://www.techhub.training/u/Keanu_Gauthier)\
**Post date:** [January 25, 2025, 11:21pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/5 "2025-01-25T23:21:33Z")

</div>

Time to complete: 1h  
Rating: intermediate  
Comments: really fun challenge that reminded me of the python class I had last semester which I really enjoyed. Even though I used chatgpt to code I still had to go back and fix some errors. It had me go back to my compiled codes from last semester.

import pandas as pd  
import os

# Load the data file into a pandas DataFrame

data\_path = os.getcwd()+“\Accounting\_Terms\_Updated\_Explanations.xlsx”  
data = pd.read\_excel(data\_path)

# Create a dictionary where terms are keys and explanations are values

terms\_dict = dict(zip(data[‘Term’].str.lower(), data[‘Explanation’]))

while True:  
# Prompt the user to type in the accounting word they want to learn  
user\_input = input("Type an accounting word you want to learn: ").strip().lower()

```
if user_input in terms_dict:
    # If the word is in the dictionary, print the explanation
    print(f"\n{user_input.title()}: {terms_dict[user_input]}\n")
else:
    # If the word is not in the dictionary
    print("\nSorry, that word is not in the dictionary.\n")

# Ask the user if they want to continue or quit
continue_choice = input("Do you want to continue? (yes/no): ").strip().lower()
if continue_choice != "yes":
    print("\nGoodbye! Have a great day learning accounting!\n")
    break

```

---

<div class="post-metadata">

**Author:** ![Abraham\_Reyes\_Leon](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/abraham_reyes_leon/32/7305_2.png) [@Abraham\_Reyes\_Leon](https://www.techhub.training/u/Abraham_Reyes_Leon)\
**Post date:** [January 25, 2025, 11:26pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/6 "2025-01-25T23:26:14Z")

</div>

Time to complete: 1 hour  
Rating: Intermediate  
Comments:  
I enjoyed the case; it was a great refresher on the Python class I took last year. It took about an hour to complete, as I tested different words to ensure the code was working correctly. It was fascinating to see how combining two tools can create an interactive, personalized solution that’s useful for school.  
#chatgpt Case  
import os  
location = os.getcwd()+“\Accounting\_Terms\_Updated\_Explanations.xlsx”

import pandas as pd

# Load the data file into a pandas DataFrame

data = pd.read\_excel(“Accounting\_Terms\_Updated\_Explanations.xlsx”)  
terms\_dict = {term.lower(): explanation for term, explanation in zip(data[‘Term’], data[‘Explanation’])}

while True:  
word = input(“Enter an accounting term to learn (or ‘quit’ to exit): “).strip().lower()  
if word == ‘quit’:  
print(“Goodbye! Have a great day learning accounting!”)  
break  
explanation = terms\_dict.get(word)  
if explanation:  
print(f”\n{word.title()}: {explanation}\n”)  
else:  
print(“\nSorry, that word is not in the dictionary.\n”)

---

<div class="post-metadata">

**Author:** ![jason\_ng](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/jason_ng/32/7316_2.png) [@jason\_ng](https://www.techhub.training/u/jason_ng)\
**Post date:** [January 28, 2025, 1:15am UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/7 "2025-01-28T01:15:57Z")

</div>

It takes me around 30 minutes to complete. The level is beginner. Here is my code.

[Challenge214\_Accounting Maestro ChatGPT.xlsx](https://www.techhub.training/uploads/short-url/57oi19hVOBkCMV2pM9uyTRrbws.xlsx) (11.7 KB)  
import pandas as pd

# Load the data file as a Pandas DataFrame

file\_path = “C:\Users\Admin\Downloads\Challenge214\_Accounting Maestro ChatGPT.xlsx”  
data = pd.read\_excel(file\_path)

# Option 1: Keep the values as a Pandas DataFrame

dataframe = data

# Option 2: Convert the DataFrame into a dictionary

terms\_dict = dict(zip(data[‘Term’], data[‘Explanation’]))

while True:  
# Prompt the user to type an accounting word  
user\_input = input("Enter an accounting term you want to learn about: ").strip().lower()

```
# Check if the word is in the dictionary
if user_input in map(str.lower, terms_dict.keys()):
    # Find the correct case-sensitive key
    key = next(term for term in terms_dict if term.lower() == user_input)
    print(f"\n{key}: {terms_dict[key]}\n")
else:
    print("\nThe word is not in the dictionary.\n")

# Ask if the user wants to continue
continue_choice = input("Do you want to continue? (yes/no): ").strip().lower()
if continue_choice not in ["yes", "y"]:
    print("Goodbye!")
    break

```

---

<div class="post-metadata">

**Author:** ![Saul\_Esplin](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/saul_esplin/32/7325_2.png) [@Saul\_Esplin](https://www.techhub.training/u/Saul_Esplin)\
**Post date:** [January 28, 2025, 4:29am UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/8 "2025-01-28T04:29:14Z")

</div>

Time to complete: 1 hr  
Rating: Intermediate  
Comments: I thought that this was a fun challenge. The accounting definitions that ChatGPT came up with were funny. This was also a good test of basic python knowledge and how to prompt ChatGPT for more specific results.

```auto
import pandas as pd
def load_data(file_path):
    """Load the Excel file as a DataFrame and convert it to a dictionary."""
    df = pd.read_excel(file_path)
    terms_dict = dict(zip(df['Term'].str.lower(), df['Explanation'])) # Convert terms to lowercase
    return terms_dict

def define():
    """Main function to interact with the user."""
    # Load the data file
    file_path = "path_to_your_excel_file.xlsx" # Replace with your actual file path
    terms_dict = load_data(file_path)

    print("Welcome to the Accounting Dictionary!\n")

    while True:
        # Prompt user for an accounting term
        term = input("Type the accounting word you want to learn: ").strip().lower()

        # Check if the term is in the dictionary
        if term in terms_dict:
            print(f"\nDefinition of '{term}': {terms_dict[term]}\n")
        else:
            print(f"\nSorry, the word '{term}' is not in the dictionary.\n")

        # Ask the user if they want to continue
        choice = input("Do you want to continue? (yes/no): ").strip().lower()
        if choice not in ['yes', 'y']:
            print("Goodbye!")
            break

if __name__ == " __main__":
 define()

```

---

<div class="post-metadata">

**Author:** ![Michael\_Barney](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/michael_barney/32/7343_2.png) [@Michael\_Barney](https://www.techhub.training/u/Michael_Barney)\
**Post date:** [February 3, 2025, 5:22pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/9 "2025-02-03T17:22:05Z")

</div>

Time to complete: 1 hr  
Rating: Intermediate

I had an enjoyable time completing this challenge. I hadn’t done any python work in a long time and it took awhile to break off the cobwebs.

def get\_definition(word, terms\_dict):  
“”"  
Finds the definition of the word/phrase in a case-insensitive way.  
“”"  
word = word.lower().strip() # Normalize input  
if word in terms\_dict:  
return terms\_dict[word]  
else:  
return None

def ask\_to\_continue():  
“”"  
Asks the user whether they want to continue or quit.  
“”"  
while True:  
choice = input("Do you want to continue? (yes/no): ").strip().lower()  
if choice in [“yes”, “y”]:  
return True  
elif choice in [“no”, “n”]:  
return False  
else:  
print(“Invalid input! Please type ‘yes’ or ‘no’.”)

def define(file\_path):  
“”"  
Main function to interact with the user.  
“”"  
# Load the data file and create a dictionary  
terms\_dict = load\_data(file\_path)

```
print("Welcome to the Accounting Dictionary!\n")
print("Type a word to learn its explanation.\n")

while True:
    # Prompt user for an accounting term
    term = input("Enter an accounting word: ").strip()
    definition = get_definition(term, terms_dict)

    # Display the result or an error message
    if definition:
        print(f"\nDefinition of '{term}': {definition}\n")
    else:
        print(f"\nSorry, the word '{term}' is not in the dictionary.\n")

    # Ask the user if they want to continue
    if not ask_to_continue():
        print("Goodbye! Keep learning about accounting!")
        break

```

if **name** == “ **main** ”:  
file\_path = “Challenge214\_Accounting Maestro ChatGPT.xlsx” # Replace with your file path  
define(file\_path)

---

<div class="post-metadata">

**Author:** ![Kiya\_Smith](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/kiya_smith/32/7349_2.png) [@Kiya\_Smith](https://www.techhub.training/u/Kiya_Smith)\
**Post date:** [February 4, 2025, 5:21pm UTC](https://www.techhub.training/t/214-python-chatgpt-accounting-maestro-chatgpt/2698/10 "2025-02-04T17:21:41Z")

</div>

Time to complete: 45 min  
Rating: intermediate  
This was actually super cool. What I did was I actually used chat gpt to take all the terms and make it into a whole new excel file the prompt I gave it was:

“this is in an excel sheet can you create a brand new excel sheet with each of the terms and a definition that matches that would make sense to a freshman in high school?”

Then it created a whole new file with terms. I think if doing this for an important project it will be important to make sure all the terms are 100% correct. The terms that I got were mostly correct but not the best explanation possible but it would be pretty easy to correct them.

Then I basically just gave chat the same exact instructions that I had from this challenge and it spit out a code that almost worked I just had to make the file path work. Then it worked great. It is cool how you can use so many platforms for studying.

this is my code:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weeklytechchallenge/original/2X/0/0452b7bc945201bf56dc5c189da76a9e0890833b.png)
