Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 please Evens / Odds Game: Evens and Odds is a game used to make a decision, like determining who goes to lunch or

Python 3 please

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Evens / Odds Game: Evens and Odds is a game used to make a decision, like determining who goes to lunch or takes out the trash. You play against a single opponent, one player declares Even or Odd, and then both players shoot. Shooting is the act of showing the other player how many fingers are in play. You can decide to show 1-5 fingers, and your total plus your opponent is used to determine even or odd. If I declare Odd, and I throw 3, and the other person throws 1, then the total is 4, and even number. Since I chose odd "I lost". Our program will allow user to play multiple rounds in a row. They will also have the option to consider a round a group of best 2 out of 3. Single play is when a single trial of even or odd determines the round. Best 2 out of 3 awards the round to whoever wins 2 trials first. Functional Decomposition You must create functions in this program. You will be required to implement and use the following functions as given, with the arguments given. choose_number() - This function returns an integer from 1 to 5 inclusive (1,5). It will continually ask the user for a number. We don't expect the user to give anything other than an integer, but this function should continually ask for input until they finally provide a valid integer. If they do not enter valid input it will continually ask them until they do. Example >>> value = choose_number() Enter a number from 1 to 5 ( inclusive ) ==> 10 You must choose a value between 1 and 5 only Enter a number from 1 to 5 ( inclusive ) ==> 0 You must choose a value between 1 and 5 only Enter a number from 1 to 5 ( inclusive ) ==> 6 You must choose a value between 1 and 5 only Enter a number from 1 to 5 ( inclusive ) ==> 5 >>> value 5 >>> Choose_even_on_odd() - This function takes no arguments and returns a boolean ( True or False). It returns True if the user chooses even, and False if they do not. is_match(even : boolean, useri_number : int, user2_number : int) - This function has 3 arguments and returns a boolean. Even indicates if the player chooses the result to be even or odd. It's True if they choose even, False if they had chosen odd. The function returns True if the result matches their prediction. If the numbers add up to an even number and the even is True, then the function returns true. choose_number_of_rounds() - This function takes no arguments and returns an integer. It will continually ask the user for an integer input from 3 - 15, inclusive. (3, 15). Very much like the function above. (Since these functions are so similar, you may want to think of a way to make one function that does the work of both. What would you pass to this function?) You'll want to implement more functions and will be graded on those that you provide. You MUST provide at LEAST 2 more functions. Sample Program > > > ==EEEE EEEEERESTART ESSEEEEEE Even Odd game 1. Play singles 2. Play two out of 3 rounds Q. Quit Invalid choice, you must select 1, 2, Q Even Odd game 1. Play singles 2. Play two out of 3 rounds Q. Quit I > 9 Invalid choice, you must select 1, 2, Q Even Odd gane 1. Play singles 2. Play two out of 3 rounds Q. Quit **> 1 How many rounds would you like to play? (3-15) ==> 2 You must choose a number from 3-15 inclusive, How many rounds would you like to play? 3-15) ==> 16 You must choose a number from 3-15 inclusive How many rounds would you like to play? (-15) ) 4 Round 1 of 4. Scare o to O Enter a number from 1 to 5 (inclusive @ You must choose a value between 1 and 5 > only Enter a number from 1 to 5 ( inclusive ) ==> 6 You must choose a value between 1 and 5 only Enter a number from 1 to 5 ( inclusive) ==> 4 Enter E for even or o for odd ==> i You must enter E or O only. No other characters. Enter E for even or o for odd ==> 5 You must enter E or O only. No other characters. Enter E for even or o for add ==> 0 The computer chose 4. 4+4 is even. You lost Round 2 of 4. Score @ to 1 Enter a number from 1 to 5 ( inclusive ) --> 3 Computer chose even The computer chose 1. 1+3 is even. You lost Round 3 of 4. Score @ to 2 Enter a number from 1 to 5 ( inclusive ) ==> 4 Enter E for even or o for odd -s> e The computer chose 2. 2+4 is even. You won Round 4 of 4. Score 1 to 2 Enter a number from 1 to 5 ( inclusive ) ==> 2 Computer chose odd The computer chose 5. 5+2 is odd. You lost Sorry you lost. You only won 1 of 4 or 25.00% of the games Even Odd game 1. Play singles 2. Play two out of 3 rounds Q. Quit ==> 2 How many rounds would you like to play? (3-15) --> 3 Round 1 of 3. Score @ to e Enter a number from 1 to 5 ( inclusive ) ==> 3 Computer chose even The computer chose 1. 1+3 is even. You lost Enter a number from 1 to 5 ( inclusive ) ==> 2 Enter E for even or o for odd --> e The computer chose 4. 4+2 is even. You won Enter a number from 1 to 5 (inclusive ) ==> 4 Computer chose even The computer chose 4. 4+4 is even. You lost You won 1 to the computer 2 Round 2 of 3. Score 0 to 1 Enter a number from 1 to 5 ( inclusive ) ==> 3 Enter Erfor even on O for odd - e The computer chose 2. 23 is odd. You lost Enter a number from 1 to 5 (inclusive > ==> 1 Computer even The computer choses sin is even. You dost You wore to the computer 2 Round 3 of 3. Score e to 2 Enter a number from 1 to 5 ( inclusive ) ==> 3 Computer chose odd The computer chose 4. 4+3 is odd. You lost Enter a number from 1 to 5 ( inclusive ) ==> 5 Enter E for even or o for odd ==> e The computer chose 3. 3+5 is even. You won Enter a number from 1 to 5 ( inclusive ) ==> 2 Computer chose odd The computer chose 5. 5+2 is odd. You lost You won 1 to the computer 2 Sorry you lost. You only won 8 of 3 or 0.08% of the games Even Odd game 1. Play singles 2. Play two out of 3 rounds Q. Quit => 9 Thanks for playing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

=+ How does the intent of the several policies differ?

Answered: 1 week ago

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago