logo CodeStepByStep logo

roulette

Write a console program that simulates the gambling game of Roulette, with the following characteristics. The player begins with $10 and bets (up to) $3 per spin of the wheel. If the wheel comes up 1-18, the player wins $3. Otherwise, player loses $3. Play until the player gets $1000 or drops to $0. At the end, print the max money the player ever earned. Here is an example dialogue:

bet 3 spin 15 money 13
bet 3 spin 35 money 10
bet 3 spin 7 money 13
bet 3 spin 4 money 16
bet 3 spin 28 money 13
bet 3 spin 19 money 10
bet 3 spin 21 money 7
bet 3 spin 26 money 4
bet 3 spin 0 money 1
bet 1 spin 22 money 0
max = 16

You should break down your program into several functions, each of which helps solve the overall problem. (Because this program uses random numbers, our site cannot perfectly verify its behavior we will look to see that you have the right overall output format, but it is up to you to verify whether you are handling the spin/money logic correctly.)

Type your Python solution code here:

This exercise asks for a complete program. This should essentially be contents you could put into a file and run outside of CodeStepByStep.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve an exercise or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect tests, etc.), please

Is there a problem? Contact a site administrator.

©, all rights reserved.