Thursday, April 17, 2014

Weekly Reflection #11

This week I was introduced to a few new methods and functions that come with python. I couldn't quite wrap my head around some of the information given like augmented assignment operators and string interpolations as I didn't really finish the chapter but I still learned quite a bit. The concepts in this chapter were more shortcuts to some of the things I'd already known from the previous chapter, but they definitely made typing code easier. I learned a new game, I'd never heard of called Bagels. Bagels is a simple game you play with your friend. Your friend thinks up a random 3 digit number with no repeating digits, and you have to guess the word. After each guess, your friend gives you clues on how close your guess was. If the friend tells you 'bagels', that menas that none of the three digits you guessed is in the secret number. If your friend tells you 'pico' then one of the digits is in the secret number, but your guess has the digit in the wrong place. If your friend tells you 'fermi' then your guess has a correct digit in the correct place. However, even if you get a pico or fermi clue, you still don't know which digit in your guess is the correct one. You can also get multiple clues after each guess('fermi pico pico').
Example of the game in python












The process in designing this game was the same as the others starting with a flow chart. One of the important functions I learned this week was getSecretNum() which will generate the random secret number for this game. This chapter introduced a few new functions and methods (random.shuffle(), sort(), and join()), along with a few shortcuts. I didn't get to the other stuff though.

No comments:

Post a Comment