Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task # 1 ( 1 point ) Import the random library. Task # 2 ( 5 points ) Define named constant and global variables as

Task #1(1 point) Import the random library. Task #2(5 points) Define named constant and global variables as indicated above. Task #3(4 points) Define a function (name it roll_dice) that will generate two random integers between 1 and 6 inclusive and return their sum. Task #4(10 points) Define a function (name it wins) that will accept one integer argument (name it player). The function will return True if anyone of the players wins, otherwise, it will return False. For a player to win, the bank must be greater than or equal to MAXIMUM_BANK. Task #5(5 points Define a function (name it update_bank). The function will accept two integers (player and value). The function will add value to the bank of that player. Task #6(2 points) Define a function (name it welcome_message) that will return the string. "Welcome to the game of DICE" "Enjoy!" Task #7(3 points) Define a function (reset) that will set the banks to zero(0). Task #8(10 points) Define a function (name it play_dice) that will play a single round of the DICE game. Use a random generator to determine the player (0 or 1) to play first (name it first_player). The second player will be 1-first_player. The players will take turns to play (note that this is being simulated and the computer plays both players by using random generated numbers.) Use a while loop for the round; the end of a round is reached when a player wins. Task #9(10 points) Using if __name__=="__main__" statement, prompt user to enter the number of rounds to play (n), display the welcome message, use a for loop to play rounds and in each round, call reset function and the play_dice function. Display the number of wins for each player.

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

More Books

Students also viewed these Databases questions

Question

What are the main sub-divisions of the Materials Cost Variance?

Answered: 1 week ago

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago