Monday, January 6, 2014

Back in Business with Python!

Summary:
We spent the first week or so in the new unit learning simple python knowledge with codeacademy, after that week we transitioned into making our own projects. The first project we were assigned, was to make our own "Rock Papper Scizzors" game. This was my first experience with while loops, and importing modules, so that was difficult to get the hang of at first. The way the program works is while play is 1, the program asks the player to input a number depending on whether they want Rock, Paper, or Scissors. Then the computer randomly selects a number for Rock, Paper, or Scissors and those numbers are compared by saying if the players number is equal to one thing, and the computers is equal to another, depending on how the game would be played in real life a winner is chosen. If the player's input is not equal to 1, 2, or 3, the program requests that the player inputs an allowed number so that the calculations actually work. Finally, the program asks if the user would like to play again, if so since play will still equal 1, the program will restart, but if anything else is entered, the program will stop.
Issues:
The main issues revolved around having some variables set as strings in some areas, and integers at others. This was fixed by making the random compy variable a string using the "str()" command. 
Profit:
With this program I learned how to appropriately use while loops, import modules, and keep my strings and integers in order. Mastering the art of the while loop is very important, as it is needed for programs that need to be repeated many times. Modules are very important, as they are used often in most programs. One form of importing a module is very useful and we will visit it later.

No comments:

Post a Comment