Since I read the wrong criteria for the blog post in the beginning (I didn’t open up the assignment and see what P8 blog posts had to include), I ended up writing the most of the code for the game at home (shown above). Anyways, I’ll probably try write to meet both requirements in this post. However, my game isn’t completed yet, so I might not be able to address all the criteria.
So the main learning objective of this class was to identify and understand how to use pseudo code. So firstly, what is pseudo code? Pseudo code is the words and sentences in ENGLISH that help to tell the user what the computer is doing. Lines of pseudo code usually appear after a ‘#’, since the program doesn’t recognize anything after a hashtag. Since the computer doesn’t run this code, it is instead used for the user to read, thus requiring it to be in proper English.
Today, I also learnt more about flowcharts and why they’re important. Flowcharts help the programmer to visualize the steps to achieve something. In other words, a flowchart acts as the planning or ‘idea development’ stage of the design process. Sheel and I created a flowchart for feeding a pet. The flowchart is attached below:
-insert image here once I have access to my phone again-
So the feed your pet algorithm was a scenario where we had to apply our knowledge on pseudo code and use of flowcharts to solve the problem on when to feed a pet. My partner Sheel and I decided to choose Shiv (Sheel’s twin brother) as our pet so we based our process, code, and flowchart off of feeding Shiv. After creating the flowchart (above), we decided to write some pseudo code on PyCharm which basically takes the flowchart and changes it into sentences on a computer. Our pseudo code is shown below:
-insert pseudo code once sheel decides to send it to me from his laptop…-
Lastly, we started to work on our guess the number game in class today. The objective of this project is to program a game where the user is trying to guess the computer’s number based off of clues of whether or not the number is higher or lower than the user’s guess. In class, we established how to use a random number generator. This random number generator paired with the range will help the computer to pick a number between two integers which the user will then try to guess. The code I wrote at home is the image on the top of this post.
At home, I was able to finish up the basic structure of the game. I was able to use a random number generator to generate a number between 1-50 (my range). I was also able to incorporate the input function by allowing the user to tell the computer their name. I was also able to write some code that told the user if their guess was too high, too low, or if they guessed correctly.
However, there were some things that I wasn’t able to complete at home. For example, I have been unable to put a limit on the number of guesses the user has, so I’ve basically just copy and pasted the code over and over again to give the user an infinite number of guesses. This is something I need to work on next lesson so that I can further improve my game.