Question
Must be written in Python. The purpose of the program is to use the material from Chapter 4 (and previous chapters) to write a complete
Must be written in Python. The purpose of the program is to use the material from Chapter 4 (and previous chapters) to write a complete .py file that we can run from the command line or from within the IDE. Please do not use Jupyter notebook for this project.
Description:
The game of "23" is a two-player game that begins with a pile of 23 toothpicks. Players take turns, withdrawing either 1, 2, or 3 toothpicks at a time. The player to withdraw the last toothpick loses the game.
Write a human vs. computer program that plays "23". The human should always move first. When it is the computer's turn, it should play according to the following rules:
If there are more than 4 toothpicks left, then the computer should with-draw 4 - X toothpicks, where X is the number of toothpicks the human withdrew on the previous turn. If there are 2 to 4 toothpicks left, then the computer should withdraw enough toothpicks to leave 1. If there is 1 toothpick left, then the computer has to take it and loses. As games go, it's not all that interesting, per se. Program-wise, though, here are some additional requirements:
There must be at least 2 functions in the program. What the functions actually do, is up to you. Design the project in such a way to use the functions. Each function must be in separate .py files. Use import and/or package statements as needed. Use appropriate messages for the interaction between user and computer. Validation
Other than the Y|y and N|n for confirming repeat of the program, no other validations will be needed.
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