Question
The programming language will be Python/IDLE 5. Develop a solution to flip a coin a given amount of times, and then print the number of
The programming language will be Python/IDLE
5. Develop a solution to flip a coin a given amount of times, and then print the number of heads and the number of tails. The equation to toss the coin is: Coin = Integer(Random * 2) + 1 This is called a simulation question where you use a math function to represent mathematically what you might observe physically, by actually flipping a coin. (20 points) Your solution development should include:
a. PAC
b. Interactivity Chart
c. IPO Chart
d. Algorithms
e. Actual working python code
Additional Info, the goal of the code.
- Simulate the coin flipping process by using the Python function random() in a loop that returns a pseudo-random number each time through the loop. See the Python function random() that returns a floating point number (a decimal number) from 0 to just less than
- Since the generated random number is a decimal, you need to convert it to an integer using the given equation. This equation will ensure that you either have 1 or 2 after each random call.
- Convert that integer number to a head or a tail based on your criterion. (e.g. 1 means heads and 2 means tails)
- Repeat steps 1, 2 & 3 the number of times that is given as an input to your function.
- With each toss, update the number of heads and tails that you get.
- Print the number of heads and tails that you get.
Step 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