CECS 277 – Lab 1 – Python Basics solved

$30.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Three Card Monte

Create a program that allows the user to play the game Three Card Monte, where a player bets
that they can guess the location of the queen in a set of three cards.

The user should start the game with $100. Hide the queen in one of three places by randomizing
its location with a value between 1 and 3. Prompt the user to enter an amount to bet (check that
the user has enough money, otherwise tell them that it is invalid). Then prompt the user to enter
their guess for where the queen is hidden (check that the entered value is between 1 and 3). If it
is a match, then the user receives double their bet. Display the location of the queen and tell the
user if they were correct or not. Repeat the game until the user runs out of money or decides to
quit.

Example Output (user input is in italics):
-Three card MonteFind the queen to double your
bet!
You have $100.
How much you wanna bet? 50
+—–+ +—–+ +—–+
| | | | | |
| 1 | | 2 | | 3 |
| | | | | |
+—–+ +—–+ +—–+
Find the queen: 1
+—–+ +—–+ +—–+
| | | | | |
| K | | Q | | K |
| | | | | |
+—–+ +—–+ +—–+
Sorry… you lose.
Play again? (Y/N): y
You have $50.
How much you wanna bet? f
Invalid input – should be an
integer.
How much you wanna bet? -1
Invalid input – should be
within range 1-50.
How much you wanna bet? 75
Invalid input – should be
within range 1-50.
How much you wanna bet? 30
+—–+ +—–+ +—–+
| | | | | |
| 1 | | 2 | | 3 |
| | | | | |
+—–+ +—–+ +—–+
Find the queen: 2
+—–+ +—–+ +—–+
| | | | | |
| Q | | K | | K |
| | | | | |
+—–+ +—–+ +—–+
Sorry… you lose.
Play again? (Y/N): y
You have $20.
How much you wanna bet? 10
+—–+ +—–+ +—–+
| | | | | |
| 1 | | 2 | | 3 |
| | | | | |
+—–+ +—–+ +—–+
Find the queen: 2
+—–+ +—–+ +—–+
| | | | | |
| K | | Q | | K |
| | | | | |
+—–+ +—–+ +—–+
You got lucky this time…

You have $30.
How much you wanna bet? 30
+—–+ +—–+ +—–+
| | | | | |
| 1 | | 2 | | 3 |
| | | | | |
+—–+ +—–+ +—–+
Find the queen: 3
+—–+ +—–+ +—–+
| | | | | |
| K | | Q | | K |
| | | | | |
+—–+ +—–+ +—–+
Sorry… you lose.
You’re out of money. Beat it
loser!

Notes:
1. Place your name, date, and a brief description in a comment block at the top of your
program.
2. Your code should be defined in a main function.

3. Use the check_input module provided on Canvas to check the user’s input for invalid
values. Add the .py file to your project folder to use the functions. You may modify it as
needed. Examples using the module is provided in a reference document on Canvas.

4. Use the random module to generate your random numbers. Examples for generating
random numbers is provided in a reference document on Canvas.
5. No need to create extra functions or add lists to your code, you’ll only need the main
function with a while loop and some if statements.

6. Please read through the Coding Standards reference document on Canvas for guidelines
on how to name your variables and to format your program.
7. Add brief comments in your program to describe sections of code (you should not have a
comment describing every single line).

8. Thoroughly test your program before submitting:
a. Make sure the game re-randomizes the location of the queen every round.
b. Make sure that the user cannot enter an invalid input for the bet or the guess.
c. Make sure that the queen is displayed at the correct location.
d. Make sure that the game accurately reports whether the user chose the correct
location of the queen.
e. Make sure that the user gains the amount of the bet when they win and takes away
the amount of the bet when they lose.
f. Make sure the game ends when the user is out of money or when the user decides
to quit.