Question
Problem 3 This program you are writing from scratch. The program will simulate spinning a wheel that has been numbered 1 through 16. Not only
Problem 3
This program you are writing from scratch. The program will simulate spinning a wheel that has been numbered 1 through 16. Not only is the wheel numbered, but it also has colors and a designated jackpot value. Each time the wheel is spun, the number is output along with either the color or label for the number:
The number 16 on the wheel indicates a Jackpot.
Otherwise, it is represented by a color:
If the number divides by 3 exactly, the color is Green.
If the number divided by 3 has a remainder of 1, the color is Yellow.
If the number divided by 3 has a remainder of 2, the color is Red.
When the program starts, it will ask the user how many time to spin the wheel. The user must enter a number between 4 and 10. Then the program will simulate spinning the wheel that number of times.
Sample Output:
How many times do you want to spin the wheel? 3
Enter a number between 4 and 10.
How many times do you want to spin the wheel? 8
Spin 1: 6 ==> Green
Spin 2: 13 ==> Yellow
Spin 3: 10 ==> Yellow
Spin 4: 16 ==> JACKPOT!
Spin 5: 3 ==> Green
Spin 6: 2 ==> Red
Spin 7: 14 ==> Red
Spin 8: 11 ==> Red
Thanks for playing!
The program should have TWO functions:
main This function is the main routine. It should do the following:
Ask the user how many times they want to spin the whell. If the user enters a number less than 4 or greater than 10, the program should continue to ask the user for a valid number between 4 and 10.
Remember you can use a while loop to do input validation.
Once the program has a valid number from the user, it should use that number as an argument when calling the spin_wheel function.
spin_wheel This function has one parameter, spins, which is the number of times to spin the wheel.
Use a for loop to spin the wheel the number of times specified.
Use the randint function from the random module to get a random digit between 1 and 16 inclusive.
Print the number of the loop iteration and the spin value as indicated in the Sample Output.
The number of the loop iteration should start with 1.
The spin value should include the number and either the color of the number or "JACKPOT!" in the case of number 16.
After the for loop is complete, print a message thanking the user for playing.
Run this program. Take a screenshot of the Terminal that includes the line showing where you started the program run with the results. Name the screenshot Lab04P3-ouput.jpg.
Submit both files, Lab04P3.py and Lab04P3-output.jpg, to Blackboard for credit.
Bonus Opportunity 25 Points
This program is optional, but it will give you more practice with Python. It will also give you a chance to earn up to 25 additional points on this lab.
You will enhance the program you did in Problem 3 so the user make a bet on what appears on the wheel. The cost and payout of each spin is as follows:
Jackpot will payout $50.
Green will payout $20.
Red will cost the player $25.
Yellow will neither win nor lose.
Copy Lab04P3.py to another file and name it Lab04Bonus.py.
In the main function, ask the user how many time to spin the wheel. The program should only allow the user to enter numbers between 4 and 10 inclusive.
After asking the user for the number of spins, the program (in the main function) should then ask the user how much money they are betting.
Modify the spin_wheel function to take an additional parameter, pot, which will indicate the amount of money the user is betting. Use that parameter in the appropriate place in your function to initialize a variable to keep track of how much money the user is winning or losing. Before spinning the wheel, print a message to let them know their money has been deposited with the bank.
At the end of the spin_wheel function, a message should be printed to indicate the state of the player's winnings:
If the user has a positive amount, the message should read: "Collect $xx.xx at the cashier's window."
If the user has no money left ($0), the message should read: "All the money is gone."
If the user has a negative amount, the message should read: "You owe $xx.xx to the bank!" Note the number should be shown as a positive amount so if the amount is -20.0 the message should say they owe $20.00.
Update your main function so that it passes the additional argument to spin_wheel that indicates the amount the user is betting.
Sample Output:
How many times do you want to spin the wheel? 8
How much money are you betting? 75
$75.00 has been deposited with the bank.
Spin 1: 9 ==> Green
You win $20!
Spin 2: 9 ==> Green
You win $20!
Spin 3: 8 ==> Red
You lose $25!
Spin 4: 5 ==> Red
You lose $25!
Spin 5: 9 ==> Green
You win $20!
Spin 6: 3 ==> Green
You win $20!
Spin 7: 14 ==> Red
You lose $25!
Spin 8: 16 ==> JACKPOT!
You win $50!
Collect $130.00 at the cashier's window.
Thanks for playing!
!!!!!!!!!!!!!!!!!!!!!!!!1need help with bonus!!!!!!!!!!!!!!!!!!!!!!!!!!1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started