### Project 7: Making Decisions

In project 7 you will implement a version of the game show, “Let's Make a Deal.” Your version of the game show is famous because it demonstrates the Monty Hall paradox.

#### Exercises

Turn in exercises 27, 28, 29, 30 and 31 with this project.

#### The Monty Hall Problem

The game show starts with three doors. Behind one of them is a car. Behind the other two are goats. Monty asks you to choose a door. For argument's sake let's say you choose door #1. Then Monty opens a different door to reveal a goat.

Monty then asks you, “would you like to keep the door you chose or switch doors?” The problem is a paradox because most people (even some with a Ph.D.) think that the odds of guessing right are 50/50. They're not, you have better odds if you switch.

### Getting Random Numbers

There are two kinds of random numbers on a computer. Random numbers that are good for things like games and random numbers that are good for cryptography. Cryptographic random numbers are so random it's very difficult to guess them, but they take time to generate. The `random`

package has random numbers that are good for games.

Here's how to get a random number between 1 and 3 (including 1 and 3):

import random my_number = random.randrange(1, 4)

Use this code to generate the number of the door with a car behind it. You should assume that the other doors have the goats.

### Game Procedure

Your game starts by picking a random number (the number of the door with the car). Then prompt the user for the first guess.

Pick a door:

You program has to determine what Monty's guess will be. There are rules that govern Monty's guess:

- Monty will always pick a goat.
- If the contestant picked a door with a car behind it Monty may open any other door.
- If the contestant picked a door with a goat behind it Monty will open the door with the other goat.

You will need nested if/elif/else statements to determine Monty's pick. Once Monty decides make Monty's choice known:

Monty opens door #3

Prompt the user if they wish to stay or switch.

Do you wish to stay or switch:

The user must type “stay” or “switch” you don't have to worry about incorrect input. After the second choice reveal whether the user won the car or won the goat.

You won the car!

Test your game thoroughly. While you're developing the game it's a good idea to print out the door that the car is behind so you can verify that it works.

### Required Functions

Your program is required to have the following functions:

`monty_door`

- Arguments:
**INTEGER**The number of the door with the car behind it**INTEGER**The number of the door that was guessed by the contestant

- Returns:
**INTEGER**Monty's choice of a door

`has_won`

- Arguments:
**INTEGER**The number of the door with the car behind it**INTEGER**The number of the door that was guessed by the contestant- The “stay” or “switch” input from the contestant

- Returns
`True`

if the contestant won the car,`False`

if they won a goat.

Each function should have a docstring describing what it does.

### Requirements

- You must have a docstring describing your program.
- You must have the required functions
- The functions must have the exact names as above
- The functions must take the exact arguments in the order above
- The functions must have docstrings.

- The program must say “car” if you win and “goat” if you lose.
- All code should be in a function
- Put the game input and print functions in
`main()`

- Your program must be submitted in a file called
`project7.py`

### Advanced

The downloadable code for this week contains a stub for playing the Let's Make a Deal game using the web. Add the required functions from above and complete the game play. Note that the templates contain `if`

statements.

Requirements for the advanced version:

- You must have a docstring describing your program
- You must have the required functions from the assignment
- The functions must have the exact names
- They must take the same arguments and return the same values

- Your program must be submitted in a file called
`project7_adv.py`

- You must have the same directory layout as the download
`templates`

- Your HTML templates go here (you can name them anything you like)

`resources`

- The images must go here (you can rename them or change them if you like)

### Grading

- 5 points for the exercises
- 5 points for a correct submission
- 10 points for the correctness of your program.