Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part I Create a python program (you must have a main() function) that does the following: 1. Sets up the turtle window with some width

image text in transcribedimage text in transcribed

Part I Create a python program (you must have a main() function) that does the following: 1. Sets up the turtle window with some width and height and background color that isn't "white". To do that, do the following: a. turtle.setup({width>, ) b. win = turtle.Screen() C. win.bgcolor() 2. Creates a turtle. 3. Draws 6 dice, each with a different value (1-6). You should use a loop for this. Each dice should be: a. A square with a background of white (You should use a loop to draw a square) b. Dots that resemble a die showing a value between one and six. For example: D.. !! C. The dots should be positioned within the square at intervals of 1/4. For example: You should parameterize this part of the program so that you can easily adapt it for the next part. That means, you should use variables for: 1. Dice Value (number of dots that appear) 2. Location on the window (x,y) of the upper left-hand comer 3. Size of the dice (width) 4. Size of the dots (which should be the width of the dice // 6) Part II Modify the program so that two more dice are drawn on the screen (not on top of the other 6). The two new dice should be set to show random numbers between 1 and six, as if they were rolled. Each time you run the program, they should display different values. To set a random number, you want to first import random at the top of the program. Then set the die value to randomrandint(1,6). Part III Compute and print the probability of rolling the sum of the dice from Part II. There are a total of 62 = 36 ways to roll 2 dice. The number of ways to roll a value of Xis: X-1 13- X if X is 7 or less otherwise So the probability is the number of ways of rolling X divided by 36. For example, there are 7 -1 = 6 ways to roll the number 7. Therefore, the probability of rolling a 7 is 6/36 = .1666667 = 16.6667 %. The output (which will appear on the console) should be as a percentage formatted to 4 decimal places. This is an example of what your program should produce (it does not have to look exactly like this): ** *****= RESTART: /home/cferner/classes/csc131/DiceTest.py - SSSSSSSSS The probability of rolling a 5 is 11. 1111 % Part I Create a python program (you must have a main() function) that does the following: 1. Sets up the turtle window with some width and height and background color that isn't "white". To do that, do the following: a. turtle.setup({width>, ) b. win = turtle.Screen() C. win.bgcolor() 2. Creates a turtle. 3. Draws 6 dice, each with a different value (1-6). You should use a loop for this. Each dice should be: a. A square with a background of white (You should use a loop to draw a square) b. Dots that resemble a die showing a value between one and six. For example: D.. !! C. The dots should be positioned within the square at intervals of 1/4. For example: You should parameterize this part of the program so that you can easily adapt it for the next part. That means, you should use variables for: 1. Dice Value (number of dots that appear) 2. Location on the window (x,y) of the upper left-hand comer 3. Size of the dice (width) 4. Size of the dots (which should be the width of the dice // 6) Part II Modify the program so that two more dice are drawn on the screen (not on top of the other 6). The two new dice should be set to show random numbers between 1 and six, as if they were rolled. Each time you run the program, they should display different values. To set a random number, you want to first import random at the top of the program. Then set the die value to randomrandint(1,6). Part III Compute and print the probability of rolling the sum of the dice from Part II. There are a total of 62 = 36 ways to roll 2 dice. The number of ways to roll a value of Xis: X-1 13- X if X is 7 or less otherwise So the probability is the number of ways of rolling X divided by 36. For example, there are 7 -1 = 6 ways to roll the number 7. Therefore, the probability of rolling a 7 is 6/36 = .1666667 = 16.6667 %. The output (which will appear on the console) should be as a percentage formatted to 4 decimal places. This is an example of what your program should produce (it does not have to look exactly like this): ** *****= RESTART: /home/cferner/classes/csc131/DiceTest.py - SSSSSSSSS The probability of rolling a 5 is 11. 1111 %

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

2. What do you believe is at the root of the problem?

Answered: 1 week ago