Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python (.py file) Note: Please comment the steps and post a screenshot of your output, source code, and trials. Also include the spaces, indents, and
Python (.py file)
Note: Please comment the steps and post a screenshot of your output, source code, and trials. Also include the spaces, indents, and new lines. Thank you.
Part 2: Pick Up Sticks For this assignment you will be creating an interface for two humans to play a simple game of "Pick Up Sticks'. Here's how the game is played in the "real world . The game begins with a number of sticks on a table (between 10 and 100) . Each player, in turn, takes between 1-3 sticks off the table The player to take the last stick loses. Your job is to build a virtual version of the game using Python. Here are a few sample runnings of the program Run #1 How many sticks are on the table? (enter a number between 10 and 100): 10 There are 10 sticks on the table, Turn: Player 1 How many sticks do you want to remove from the table? (1, 2 or 3):3 There are 7 sticks on the table. Turn: Player 2 How many sticks do you want to remove from the table? (1, 2 or 3):2 There are 5 sticks on the table. Turn: Player 1 How many sticks do you want to remove from the table? (1, 2 or 3):3 There are 2 sticks on the table. Turn: Player 2 How many sticks do you want to remove from the table? (1, 2 or 3):1 There are 1 sticks on the table. Turn: Player 1 How many sticks do you want to remove from the table? (1, 2 or 3):1 Player 1 loses! Run #2 How many sticks are on the table? (enter a number between 10 and 100): 150 Invalid # of sticks, please try again. How many sticks are on the table? (enter a number between 10 and 100):- Invalid # of sticks, please try again. How many sticks are on the table? (enter a number between 10 and 100): 10 There are 10 sticks on the table. Turn: Player 1 How many sticks do you want to remove from the table? (1, 2 or 3):3 There are 7 sticks on the table. Turn: Player 2 How many sticks do you want to remove from the table? (1, 2 or 3):3 There are 4 sticks on the table. Turn: Player 1 How many sticks do you want to remove from the table? (1, 2 or 3):3 There are 1 sticks on the table. Turn: Player 2 How many sticks do you want to remove from the table? (1, 2 or 3):1 Player 2 loses! Here are some hints to get you started: You should begin by letting the user decide how many sticks they will start off with. You can assume that the user will select a number, but you need to make sure that the selection was between 1-3. Hint:use a while loop You will need to keep track of turns in the game ie Player 1 s tur Player 2's turn, etc However, it might be eas er to take care of this later in the game when you begin writing your program you might want to design the game to only work with one player to begin with (i.e. it's always Player 1's turn) and then you can add in the functionality for player 2 later on once you've perfected the mechanics for Player 1 Each player can take between 1 and 3 sticks from the table. They cannot take more than 3 or less than1 . You need to make sure the players don't take more sticks than are on the table (i.e. if there are 2 sticks left the user cannot take 3) When there are 0 sticks on the table the player who took the last stick is the loser. The game ends at this pointStep 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