Project #1: Python Slot Machine

Introduction And The First Step

My class and I were tasked with creating 3 projects over 6 weeks. A python coding project, a CAD project, and an arduino robotics project. I decided to start with the python project and created a Slot Machine. These are some of the various steps I went through in order to make this a possibility.

First, I needed to create a FlowChart in order to project what my final product was going to look like.

Quick note before I begin, I have highlighted the comments in a light green for organization.

After finishing the FlowChart, I started with the slot machine system portion and added a random number generator that will draw randomly from all the numbers in the “box” and put them into my code. I made sure that the numbers/signs that will give you more money like the “7” and the “$” had a much smaller chance of being rolled to make it harder than it looks to get a jackpot. After, I created a function that when ran, prints “WELCOME TO THE SLOT MACHINE” and then ran it.

I set up the function where it actually asks whether or not you would like to roll as long as you have 5 dollars left. If you say that you would like to roll, it prints the 3 digits that you got in a “# # #” order and you will lose 5 dollars so as to simulate the price of the slot machine.

To the right you will find the different conditions in which you get money. I made it so if you get a “# $ #” it is worth more than a “# # $” or a “$ # #” because it looks more aesthetically pleasing. I also made a regular jackpot where if all the numbers are the same, you get 750 dollars. I made a double jackpot for 1k dollars if you get three sevens and a super jackpot that beats the game and gives you 10K if you get three $ signs in one roll. I made sure that all of these chances with the exception of the “# $ #” have a lower chance of you getting them then the amount of money they give you. As an example, the chance to get a “$ # #” is a 1/30 chance because there are 30 numbers in the box and only one of them is a dollar sign, but it only gives you 25 which is much less than what it should give.

Here was the final thing to make my coding work; conditions to end the game. This just shows that if you say no to the offer of rolling, you walk away and do not gamble which ends the game. The other option is that if you were to get over 10,000 dollars, you would win.

Here was the final thing to make my coding work; conditions to end the game. This just shows that if you say no to the offer of rolling, you walk away and do not gamble which ends the game. The other option is that if you were to get over 10,000 dollars, you would win. The picture will be shown down below.

Please note that for some reason no matter what you say in response to the asking whether or not you would like to roll, it will roll for you unless you say “N”. This is not supposed to happen and I believe it is a glitch with the python coding website I am using.

After all of this, the final output will look like this:

click here to access the code on a google doc


Comments

2 Responses to “Project #1: Python Slot Machine”

  1. mcrompton Avatar
    mcrompton

    OK, Thomas, this is a good start. You clearly have some understanding of basic Python and have created a working game. There are a few things that I need you to think about and do. First, You are required to comment your code and define and use a function. You have not done this in your current code. Please edit your code. Second, your flowchart isn’t bad, but you seem to be flowcharting your process for completing the project, not flowcharting the flow of the code itself. They are similar, but not the same. Can you please edit your flowchart. Finally, your UI has an interesting bug. If I submit a response of “y”, I don’t actually play a spin. You need to either present an error to the user telling them that you are expecting a “Y” rather than a “y”, or build into the code something that makes “Y” and “y” equivalent. Can you please address at least the first two issues and resubmit your assignment? Thank you.

    1. mcrompton Avatar
      mcrompton

      Thank you for addressing these issues, Thomas.

Leave a Reply

Your email address will not be published. Required fields are marked *