Question: Python 3 via PyCharm - Purpose: To practice the use of conditionals and simple loops. Degree of Difficulty: Easy. The code is not very difficult,
Python 3 via PyCharm
-



Purpose: To practice the use of conditionals and simple loops. Degree of Difficulty: Easy. The code is not very difficult, but make sure you understand the described program behavior. The game of Morra is a hand game that dates back to ancient Greece and Rome. Any number of players can play, but we will assume that there are always only two players. The game is played in rounds. Each round, players throw out one hand showing between O and 5 fingers extended and simultaneously call out what they think the sum of the fingers on the hands of all players will be. Any player who guesses correctly gets a point. The first player to 3 points wins. You will write a program that simulates a two-player game of Morra. Your program must do the following for each round of play until the game is over . At the beginning of each round, print out the round number. The first round is round 1 . Read as input from the console the number of fingers to be played by player 1, the number of fingers . Report by printing to the console whether any players made a correct guess, and if so, that player's . If any player now has two points, report that they only need one more point to win (it's OK to do this to be played by player 2, player 1's guess at the sum, and player 2's guess at the sum. new point total If neither player guessed correctly. print a message indicating this. for one player even if the other now has three points and is about to win.. this will happen when any player wins by a score of 3 to 2). Once the game is over, print the final outcome of the game. There are a few possibilities: . Print Player X wins! where X is either 1 or 2 depending on which player won . If, however, the winning player won by a score of 3 to O. instead print Player X wins a glorious victory!, again whereX is either 1 or 2 as appropriate. It is possible that the game is a tie. For example, if the score is 2 to 2,and both players guess correctly in the next round, both players will have three points when the game ends. In such a case, instead of printing either of the above messages. print It's a tie! . Sample Runs A couple of sample runs demonstrating program behaviour are given in the appendix at the end of this document (this is not because they are unimportant, but because they are rather long to insert here). Tips and Hints (a) Remember: you don't have to generate player moves randomly. You are reading them from the con- sole each round. Think of your program as the referee - it asks for the players moves each round using console input, then reports on the outcome of each round using console output, and finally prints the outcome of the game (b) Your program only has to play one full game. To referee another game, run the program again! (c) You may assume that the user enters only valid data. That is, you do not have to actually check whether player moves are between O and 5 and that their guesses are between O and 10. Just assume that valid values are always entered. Purpose: To practice the use of conditionals and simple loops. Degree of Difficulty: Easy. The code is not very difficult, but make sure you understand the described program behavior. The game of Morra is a hand game that dates back to ancient Greece and Rome. Any number of players can play, but we will assume that there are always only two players. The game is played in rounds. Each round, players throw out one hand showing between O and 5 fingers extended and simultaneously call out what they think the sum of the fingers on the hands of all players will be. Any player who guesses correctly gets a point. The first player to 3 points wins. You will write a program that simulates a two-player game of Morra. Your program must do the following for each round of play until the game is over . At the beginning of each round, print out the round number. The first round is round 1 . Read as input from the console the number of fingers to be played by player 1, the number of fingers . Report by printing to the console whether any players made a correct guess, and if so, that player's . If any player now has two points, report that they only need one more point to win (it's OK to do this to be played by player 2, player 1's guess at the sum, and player 2's guess at the sum. new point total If neither player guessed correctly. print a message indicating this. for one player even if the other now has three points and is about to win.. this will happen when any player wins by a score of 3 to 2). Once the game is over, print the final outcome of the game. There are a few possibilities: . Print Player X wins! where X is either 1 or 2 depending on which player won . If, however, the winning player won by a score of 3 to O. instead print Player X wins a glorious victory!, again whereX is either 1 or 2 as appropriate. It is possible that the game is a tie. For example, if the score is 2 to 2,and both players guess correctly in the next round, both players will have three points when the game ends. In such a case, instead of printing either of the above messages. print It's a tie! . Sample Runs A couple of sample runs demonstrating program behaviour are given in the appendix at the end of this document (this is not because they are unimportant, but because they are rather long to insert here). Tips and Hints (a) Remember: you don't have to generate player moves randomly. You are reading them from the con- sole each round. Think of your program as the referee - it asks for the players moves each round using console input, then reports on the outcome of each round using console output, and finally prints the outcome of the game (b) Your program only has to play one full game. To referee another game, run the program again! (c) You may assume that the user enters only valid data. That is, you do not have to actually check whether player moves are between O and 5 and that their guesses are between O and 10. Just assume that valid values are always entered
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
