Question: Question 3 (10 Points) Coin Toss Program Write a well-documented Python program, hmwk5Q3.py, to simulate playing a game where a US penny (radius of 3/8


Question 3 (10 Points) Coin Toss Program Write a well-documented Python program, hmwk5Q3.py, to simulate playing a game where a US penny (radius of 3/8 inches) is tossed into a board with a 1-inch by 1-inch square. The player wins only if the penny lands entirely within the square. Estimate the probability of winning by repeating the game 10,000 times. Record the estimate of the winning chance as a comment. Your program calculates the winning probability by taking the number of wins in the simulation and dividing it by the number of trials. Hints: Import the random module and use the function random twice to simulate where the center of the coin lands in the x and y dimensions. Grading: Correct main (+4 points). Correct if statement construction (one) (+4 points). Correct estimate for the winning probability (+2 points). Question 1 (10 Points) Average Number of Times It Takes to Roll Six on a Die Write a well-documented Python program, hmwk5Q1.py, to simulate the rolling a die until the number SIX is first obtained. Repeat the experiment 100,000 times and print out the "Average Number of Rolls to obtain a Six on a Die", along with the average value. Include the average number of rolls your program calculates as a comment. Hints: Consider two repetition loops in your program. The outer repetition repeats the number of times to perform the experiment. The inner repetition repeats the single event of rolling a die an indeterminate number of times until a six is first observed. Import the random module and use the function randinto. Grading: Correct main0 (+4 points). Correct for-loop (+4 points). Correct result written as a comment (+2 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
