I made this program for a course on codecademy. It was my first program using python (or any other language) and even tho it might be a simple one, i am very proud of it. Because i did not google for nothing apart from one or other syntax ;P and i got help from someone at the last commit, as i say in the commit comment.
Here goes the github link:
https://github.com/Shizukise/slot-machine-terminal-game
The code itself is a simple one. I used the random module to get a list of 3 different numbers and after i made a function to translate those numbers to symbols. Symbols that were atached to the allowed numbers on a dictionary.(Being the symbol the key and the number the value.)
then i made a class to hold a player name and balance that we take from inputs and to define a method to give a litle welcoming c:
The biggest challenge was the game class itself and the for loop that came after. The class holds a player and its balance. And then the place bet method. this method takes the player balance.
Lastly we make a for loop inside a while function to keep iterating while the count variable is higher than 0. this variable is taken from an input also.
while this is true, we iterate trough the range from 0 to count and for each iteration we call the play and slotrow variables that hold the random function and we call the place bet method. The place method takes the amout being bet and if the balance is enough the bet will be made returning 2 times the value of the bet in case of 3 equal symbols, 1.5 times the value of the bet in case of 2 equal symbols, and taking the bet ammount from the player balance in case of 3 different symbols.
It could be prettier in the terminal but apart from that i am really happy from this and looking forward to keep learning :D
Top comments (4)
Nice Job, you should improve the README.md on GitHub ;)
Thank you! i gave a look on how to do one thanks! I will try and get the hold of markdown too XD
Hey NICE job Galopin !!
just looking thru some posts but I am not coding in Python only Java and Javascript so cannot help with the code. Best for u to brush up on For Loops because they are VERY important in all programs.
Thanks!! :D Since it was the part i kinda got stuck, i will definitly!
once again, thank you on the apreciation and thanks for the advice!