Amandas final baseball program

by Amanda Baker

22 Jun 2017

Below is my embed link:

Reflection: Writing this reflection means that this class is over, but my programming life has just begun. I want to reflect briefly on the class prior to my reflection on my program. Ever since programming became a “thing” in my life (whether a friend was in a class, it was mentioned somewhere, a professor said it would be useful, etc.) I had this idea in my mind I would not be able to do it. The concepts seem so abstract, the idea of creating something line by line was unfathomable. I can honestly say regardless of my skill level at this point, I am truly surprised and amazed I got this far. I plan to continue taking more classes, learning more about python and seeing if I can break through the barrier in my mind preventing me from lifting off. While coding as much as possible is the only way to get better, I would love any advice you may have to keep me going. Now, for the baseball program. When I first saw the description of what we needed to do I was slightly disappointed. I had been hoping to create a sort of trivia/jeperty/brain teasers game and I could not figure out how it was possible to do so. After completing the baseball project though, I have an entire game-plan in my head ready to be written. However, once I got to thinking, I realized I loved sports and many other people do too. The issue is that sometimes stats are hard to find. You can look things up player by player or team by team, but why not have it all at your fingertips? Sorting through meaningless data on a website does nothing but frustrate the user. My intention was to create a program that could take this user input and give them the information they would truly want back. After a few mishaps with data, I finally had my datafiles. These datafiles are not as clean or clear as I would like them to be, but I was able to create an interface that would return the user back clean data. My first challenge was to break things into milestones. Looking back at my drafted list (which I never even posted since it was too advanced and I broke it down anyway) I realized I needed to take a step back and break each big idea into smaller ideas like we talked about in class. So instead of “create a dictionary of dictionaries with x, y, z” instead, I began to think to break things down into lists, trying to print etc. until I had an idea of what I was doing. This was not as successful as I had imagined. I found out dictionaries were not as clear to me as I had hoped, so I struggled immensely trying to break through that barrier. During that struggle, I began to create my help dictionary, and main while loops for my program. The while loops were easy to create, and have gotten more extensive as the program has grown. One small bug that does not impact anything is when the user is entering whether they want a team, player, more or to quit. After it goes through the loop twice, it brings up a message to please enter a number. Regardless of what you enter (I believe) it brings you right back into the input to enter another team or player etc. I am still working on this and I am hoping it is solved by the time my program is handed in. My biggest breakthrough was on Monday when I thought all hope was lost. I started thinking there needed to be an easier way for me to understand how to create the dictionary of lists/dictionaries I wanted. I started googling nested dictionaries and thought it would be best to just read the python documentation. I found out about dict comprehension here: https://www.python.org/dev/peps/pep-0274/. Then, I did some further exploration to understand it more. Here are some of those links: https://www.smallsurething.com/list-dict-and-set-comprehensions-by-example/,https://stackoverflow.com/questions/14507591/python-dictionary-comprehension, and I think this article helped me understand dictionaries more: https://www.datacamp.com/community/tutorials/python-dictionary-tutorial#gs.4HYr=CU

so, after I read about this, I did some trial code which appears in my final and in this trial trinket: <iframe src=”https://trinket.io/embed/python3/871d9a3f0b” width=”100%” height=”600” frameborder=”0”

I don’t have most of them in here but my main process of figuring things out was to print literally everything. I wanted to see what each value would return. I tried single values, multiple values and other combinations. Finally, a good two+ hours later, I was pretty sure I understood it, for at least the confines of this program. I do know I need to practice this more to cement it in my brain and to fully understand it. At this point, I started coding for my two spread sheets to start being able to get user input and coding that into my logic of my functions. This was both invigorating and frustrating. It worked most of the time but every occasionally, I would catch myself potentially forgetting an index value or doing simple syntax errors with the larger print statements. During this part of the process, my friend Anthony was there witnessing the change of emotions that would occur each time I hit the run button. Every occasionally, I would ask him if he could see an error or ask him to help me get to the line since counting to line 187 might take a while. He would be able to let me know if, for example, I was off by a space. He would read it aloud since sometimes hearing someone else say it helps you figure out what you did wrong. While he is not a coder, having someone present while I was hacking away really kept my confidence up and ensured I did not give up so easily. I have lost my confidence as the semester wore on and I was hesitant to ask for help directly. I would put it in most of my homework assignment comments hoping to get feedback and piece it together myself. However, I could figure this part out and make something that I am proud of During this project, I developed a strong strategy of figuring out why something was not working the way I wanted it to. If I had an issue, I would try to break it down line by line. If I was working in a for loop with logic inside it and it was not returning what I wanted, I would maybe just have it return a value, then I would try to add a simpler logic statement, print that, and see what happened. This process really helped and made each issue seem super small and manageable instead of dealing with even five lines of code and not knowing where to start. When it came to making a class, I had no idea what I would do. Talking to Zach about his game, I off handedly mentioned, “Why don’t you make your class your user and then put your save game file in there.” When I sat down to add my class, I remembered what I said to Zach and thought that might be a wonderful thing to add to my program. I wanted the user to be able to save their session so they knew what they had searched just in case they needed this info for something. As I started coding the class, I realized I would have so, so many variables to pass to the class so I started wondering, is there a way to pass all your variables to a class? I knew that you could do import *, so I started thinking there might be something similar for classes. My thoughts turned to a google search where I found: https://stackoverflow.com/questions/32005839/how-to-pass-multiple-parameters-to-class-during-initialization At this point, I thought I kind of understood it so I started coding away. I wanted to first save the users input (Not sure if I can get further than that because of time, unfortunately). However, the issue I was getting is that it was only returning the last name from a (self, *args). After a while of printing, thinking and trying to figure out what was happening, I just thought of removing the self-variable and everything worked! Although this was really challenging, the four or so hours I put into it were worth it because it begun to restore some of my confidence I lost along the way. I want to thank Zach for being so invested in my program. He spent quite a lot of time hacking away at dictionaries too to see if he could make a breakthrough in creating the original idea I had. Although the both of us were not able to figure it out the original way I had planned, it really made me realize that sometimes everyone hits a brick wall and its what you build to get over it that matters.

Milestones

  • find and import two data files
    • create one customer module
    • create a help dictionary for the user in each place where the user will need one. Remember to do these one at a time.
    • create my while loops to run my program
    • make a list for my players in both datafiles
    • create a dictionary or some type of mapping to map the player id with their stats
    • can take user input about what stats they want
    • create a class
    • [] create a save session option. This is sort of in the process. This was an added thing I realized I could do on Wednesday and really wanted to focus on the rest of my program before trying to add cool things to it. While I really wish I could have this entirely implemented into my program, I am happy that I was able to get it started and think it would be easy to finish if I had even another 24, but preferably 48 hours.
    • create multiple stats a user can collect (not at once, but over a period of running the program
    • print the data in a visually appealing way. I think I succeeded with this well for not being able to arrow through the input and be able to tell if there are things wrong with it.
    • use at least one for loop, but start with one
    • understand dict comprehension
    • understand * arg
    • understand kwargs I think this was more for myself, but I am not entirely sure if I am there yet. Since I did not need to use it in my program, it is something I can work on in the future.
    • print my dictionary pretty! Although we talked about it, I used this website to understand it more: https://pymotw.com/3/pprint/index.html
Amanda is a Masters student at UNC studying Information Science. Outside of class, Amana is an avid reader, loves music, and loves outdoor sports. Find Amanda Baker on Twitter, Github, and on the web.