This is the final project for our class, Computer Science. For this past term, we have been learning the basics of coding with python. For this project, we had to create a basic chatbot that would at the very least respond to different questions. With what I know about operators, functions, and print functions, I implemented it into my code. Below is the result of lots of time, effort, and creativity!
I recommend for anyone that is looking at the coding, to start at the bottom and compress all the lines before looking into everything. You can press the little arrows next to the # of the line.
I am very proud of my work, considering this was my first time creating something like this and with little experience in coding. I had to do a lot of research and lots, and I mean lots of experimenting with different functions on Trinket.io. I even had my cousin, who has years of experience with coding, edit my code.
I've enjoyed every moment that I have spent working on this project, including the times when I was unsure or frustrated with the code. I would like to share a bit of my process on how these 906 lines of code came to be.
I knew going into this project that I would find it difficult to keep things simple. In my head, I want to make the computer respond to every possible outcome, or at the very least every most likely possible outcome. Except, I don't know everything! I had to make this simple, so I focused on responses from asking yes or no questions. I began drafting the ideas from my head onto paper.
Below is a photo of my ideas and concepts for this chatbot. I didn't have a solid plan, but I wrote down whatever ideas had come to mind. It is very messy and I don't expect anyone to understand all of it, but I've put this here because I thought it would be interesting to show the origins of the code.
ALL (2020), Raw Ideas and Brainstorms for my Chatbot Code |
A lot of the concepts written here were not implemented into the final code or even my first draft, but writing down any ideas helped with my process. This next code is the first draft of the code itself. This was before I understood or even knew that while loops, def functions, and other coding tricks existed!
If you can't see, I defined the function begin(str) several times throughout the entire code. I didn't know that defining a function was like customizing a bunch of actions into one word for the computer to use. I assumed that it was something that I would have to use over and over again, like the word print. I also oversimplified other print functions like time.sleep, and the os.system, that were helpful with keeping typing short, but were unecessary.
If you click onto the hold.py folder, you can see the renewed version of the code that a family member of mine provided me. I didn't understand everything he did at first, but after messing around with the code, I realized that he had organized parts of the conversations I wanted to print out into groups of functions. At the very bottom of the folder you will see:
Startup()
ColorSection(col)
importSection()
conversationSection(nam,col, whatIsColor)
All that text into 4 lines! I did not end up using this idea in my final code because I didn't fully understand how the functions were printing with the input questions. Looking at my cousin's coding helped me understand what my code should look like. If I didn't receive his help, my code would look way messier and be way longer than necessary.
Thank you for reading this far in! If I had more time to complete this project I would add more discussion between this chatbot and the user. I am still very satisfied with the work I hope that maybe some of my work can help someone else with their first time coding. This was a lot of fun, and one of my favorite projects so far.
Comments
Post a Comment