To begin this week we began a little more practice with Python. An exercise we tried to practice functions was to create a magic 8 ball. I have a good amount of experience with Python so it wasn’t super hard to mimic the basic functions of a traditional magic 8 ball so I wanted to add some extra features to make it more accessible to a user other than the programmer.
def magic8ball(str): script = ["It is certain","It is decidedly so","Without a doubt","Yes definitely","You may rely on it","As I see it, yes","Most likely","Outlook good","Yes","Signs point to yes","Reply hazy, try again","Ask again later","Better not tell you now","Cannot predict now","Concentrate and ask again","Don't count on it","My reply is no","My sources say no","Outlook not so good","Very doubtful"] answer = random.choice(script) return print("You asked: \n" + str + "\nThe MAGIC 8 BALL says: " + answer)
This function that I created requires a string as the argument and if the function is called with a string as the argument it will then run all that is inside the function. For the purposes of my magic 8 ball the argument will be the question asked by the user. The first thing the function does is save all the possible answers of a magic 8 ball in a list that it can then choose from right after using
random.choice. This will give us a random answer from the list of answers. The function ends by returning a string that will say “You asked: (user’s question)
The MAGIC 8 BALL says: (random answer)”
print("Welcome to the MAGIC 8 BALL!") user = input("Do you have a question to be answered? ") if user.lower() == "yes": question = input("What is your question? ") magic8ball(question) else: print("Goodbye.")
This is the main body of code which will first welcome the user with a message then ask the user if it wants to even ask the magic 8 ball a question. If the user answers “yes”, regardless of capitalization, it will then call the magic8ball function from earlier with the user’s question as it’s argument. If the user answers anything else it will just say “Goodbye” and finish running.
I was happy how I made my code and how it turned out because it makes it more similar to an actual magic 8 ball by allowing the user to ask a question. The only thing I would probably add is to prompt the user to ask another question if they want to and continue to run until they say no.
On Wednesday I did my peer teaching on Quest since that is the program I plan on using for my big project. I think it went well. I went through a full tutorial on pretty much all the basics to make a simple game. Such as, creating rooms, connecting the rooms, adding actions to objects, implementing score or health, and showing a quick example of how to program a game over screen. I did my tutorial by starting a new game from scratch at the beginning of class to show that it isn’t too difficult to add all these things in about 15 minutes. I also showed the group the text adventures Quest help page because it has literally everything you would need to add more detail to the base game I created in class.
On Friday I sat at table 6 to see Chris Tydings’ lesson on Microsoft PowerToys which seems like a very useful software. In short terms it is an expansion of the already available shortcuts and features on Windows OS. It has a lot of cool features like image resizing, color picker, and power rename. It adds a lot of extra keyboard shortcuts and allows keyboard shortcut mapping which is really cool especially since I have been trying to use more keyboard shortcuts recently because I find it makes navigating Windows a lot more efficient. Overall, Chris’ lesson was very informative and made me go out and download PowerToys as well.
I submitted my proposal for my big project and I have edited my topic a bit. My submitted plan is that I will be making a text based adventure game with the goal of showing the repercussions of unethical digital practices. I want to make the character play as almost a villain navigating the internet, maybe he/she is a hacker, and the player will do certain actions for their own gain but you will actually be hurting a lot of people and, spoiler alert, the end will not actually be a very happy ending for the main character. At least that is my current idea for it. I plan on creating a storyboard to really organize my thoughts for the plot of this game.
I think the semester is going well for me so far. I seem to be learning a lot of things and class is fun since there is a lot of interactive activities associated with our curriculum. Since we’re in the latter half of the semester I have been getting a bit more busy in my other classes so I have been doing some of my work a little bit last minute but so far I’ve been able to manage my time well enough to get homework done before class time so I am ready to contribute to any discussion or activities.