Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

mms (23) UI LAIS HW) File names: nim_functions.py, nim.py, test nim_functions.py For this problem, you will write a program in which the computer plays a

image text in transcribed
mms (23) UI LAIS HW) File names: nim_functions.py, nim.py, test nim_functions.py For this problem, you will write a program in which the computer plays a game of Nim against a hooman. This version of Nim works as follows. The game starts with a pile of beans, a random number between 5 and 30. A coin flip determines which player goes first. The players alternate taking beans from the pile. Each player can take only 1, 2, or 3 beans from the pile. The player who takes the last bean loses the game. Program Requirements: There's a lot of randomization and user interaction with this program, so you won't be able to test everything, and that's fine. We require two functions that can and should be tested. You must write these as described and test them in your test suite: o coin_flip: Given an integer, return the string 'H' if it's even and 'T' if it's odd. O is over : Given an integer representing the number of beans in the game, return a boolean indicating whether the game is over. You do not have to handle the case of the user entering non-numeric answers. You do not need to play strategically, the computer can choose a random number of beans for each turn, as long it's an acceptable number. Your wording doesn't need to be the same as our example, but as always your program must be friendly and informative

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

More Books

Students also viewed these Databases questions

Question

In Exercises find the indefinite integral. S X tan5 = dx

Answered: 1 week ago