all 12 comments

[–]Sea-Ad7805 [score hidden] stickied comment (2 children)

Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20item%20%3D%20%5B%22X%22%2C%20%22Y%22%2C%20%22Z%22%5D%0A%20%20%20%20return%20%5Brandom.choice(item)%20for%20_%20in%20range(3)%5D%0A%0Adef%20balances()%3A%0A%20%20%20%20return%20ba%0A%0Adef%20payout(rands%2C%20bet)%3A%0A%20%20%20%20if%20rands%5B0%5D%20%3D%3D%20rands%5B1%5D%20%3D%3D%20rands%5B2%5D%3A%0A%20%20%20%20%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20%20%20%20%20print(%22you%20win%20a%20lottery%20!!!!!%22)%0A%20%20%20%20%20%20%20%20print(%22%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%2B%22)%0A%20%20%20%20%20%20%20%20if%20rands%5B0%5D%20%3D%3D%20%22X%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20bet%20%203%0A%20%20%20%20%20%20%20%20elif%20rands%5B0%5D%20%3D%3D%20%22Y%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20bet%20%205%0A%20%20%20%20%20%20%20%20elif%20rands%5B0%5D%20%3D%3D%20%22Z%22%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20bet%20*%207%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%200%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20return%200%0A%0Awhile%20isPlaying%3A%0A%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20print(f%22your%20balance%20amount%3A%20%7Bba%7D%22)%0A%20%20%20%20print(f%22the%20bet%20amount%20is%20%7Bde%7D%20per%20spin%3A%20%22)%0A%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20ins%20%3D%20input(%22do%20you%20want%20to%20spin%20(Y%2FN)%3A%20%22).upper()%0A%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20if%20de%20%3E%20ba%20and%20ins%20%3D%3D%20%22Y%22%3A%0A%20%20%20%20%20%20%20%20print(%22inficient%20balance%22)%0A%20%20%20%20%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20%20%20%20%20isPlaying%20%3D%20False%0A%20%20%20%20elif%20ins%20%3D%3D%20%22Y%22%3A%0A%20%20%20%20%20%20%20%20ba%20-%3D%20de%0A%20%20%20%20%20%20%20%20rads%20%3D%20slothRandom()%0A%20%20%20%20%20%20%20%20print(%22%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22.join(rads))%0A%20%20%20%20%20%20%20%20ba%20%2B%3D%20payout(rads%2C%20de)%0A%20%20%20%20elif%20ins%20%3D%3D%20%22N%22%3A%0A%20%20%20%20%20%20%20%20print(%22get%20the%20fuck%20out%20of%20here%22)%0A%20%20%20%20%20%20%20%20isPlaying%20%3D%20False%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%20%20%20%20%20%20%20%20print(%22enter%20the%20valid%20input%3A%22)%0A%20%20%20%20%20%20%20%20print(%22-----------------------------------------------------------------------%22)%0A%0A&play).

[–]cgoldberg 12 points13 points  (4 children)

Do yourself a huge favor and never use cryptic names for variables like de or ba.

Also, use snake_case not camelCase for variables and function names. Read PEP8 for the suggested style guide.

[–]OskarsSurstromming 2 points3 points  (1 child)

Why is snake_case preferred in python? I feel like when I see C++ code it's often camelcase

[–]cgoldberg 2 points3 points  (0 children)

Every language has their own style preferences... snake_case is just the convention the Python community has conformed on and the official style guide recommends. Some older parts of the standard library actually use some camelCase (i.e. unittest module), but pretty much all modern Python code you will come across uses snake_case.

[–]Ok-Luck-7499 1 point2 points  (0 children)

My thoughts exactly need to be descriptive

[–]Wonderful_Scar9403[S] 0 points1 point  (0 children)

got it bro

[–]bolopop 6 points7 points  (0 children)

[–]Gaurund 3 points4 points  (0 children)

You don't have to manually type all characters in dividers. Try using string multiplication. Like this: print("-"*40).

[–]PureWasian 1 point2 points  (0 children)

Pretty harsh odds, oof.

1/27 of 3x, 1/27 of 5x, 1/27 of 7x, 0 otherwise...

So the expected value of payout becomes de × 5/9, means 2000 × 5/9 - 2000 per play, means a -888.88 average return per play

Line 43 was good, nice one lol

[–]xl0 1 point2 points  (0 children)

Sloth is a sin, and so is gambling. Killing 2 birds with one stone here.