Python Projects : The Coin Flip game v2

Hello World,
 I hope you have been doing well, today I'm going to tell you about a simple program that I made for one of my homework projects. The python code is available on my GitHub Repo if your interested.


The chapter was talking about how to have the computer generate random numbers and having some kind of interaction with the user. So the challenge was to create a program, that would "flip a coin" 5 times and then tell you how many times it got "heads" or "tails". After some trial and error I got it to run properly..so I decided to create a 2nd version.


In the 2nd version, I wanted to give the user a couple of options:
Option 1: To run through the program as many time as they liked without having to restart it.
Option 2: To choose the amount of flips the coin does.
I'm a big fan of giving the user options, I don't like to limit things to a set pattern, especially if the extended options would make the game more enjoyable (hopefully).

So I tackled Option 1 first, I was able to create a simple While loop  in which that "flipping" function happened, and as long as the user answered "yes", it would keep running that function..  Then I tackled Option 2, which had me modify the function it self to take in a user's input, make sure its a number, and place that as the number of flips, so I ended up creating a 2nd While loop to check for that.

I'm happy to say that I was able to get it running.
I have to say this is one of the programs I'm planning to use as my digital lab rat once I get to learning about GUI with Python, this and my Digital Dice program from last week's post.
Feel free to check out the code and let me know what you think.


Remember.
"Coding is the closest thing we have to a superpower" - anonymous
Go be a Super.
-ash

Comments

Popular posts from this blog

No more controllers for playing games

Look out iPhone, the G1 is coming. sw33t.