Advanced Placement (AP)

Me write this code!
starting small
to start, we're going to simulate flipping a coin 10 times. you might be thinking that isn't many coin flips, and that we could just do those flips in real life, but this is actually an important step in developing a simulation. at small scales we can make sure our code is working as intended because we can still visually confirm its output. once we're convinced that the logic of our program is reliable we'll move up to simulating larger numbers of flips.

the core logic of our program will be focused on a while loop that simulates flipping a coin by repeatedly generating random 0's or 1's using randomnumber. this is a great opportunity to keep practicing using loops while applying your knowledge of variables, iteration, and if statements.

do this:
when we want to flip a coin with a computer we will instead generate a random number between 0 and 1.
write a program that uses a while loop to flip a coin 10 times and writes the value of each flip to the screen. the example below shows how your program should run.
hint: you will need to use a counter variable in your while loop to keep track of how many times the coin has been flipped.

answer
Answers: 3

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 22.06.2019 15:00, morgan4411
Mr. jones wants to buy 6 tickets to play .each ticket cost $10. mr jones has $45 in his pocket how much more money does he need for 6 tikets
Answers: 2
image
Advanced Placement (AP), 22.06.2019 21:20, seimdakota
Which of the following is an example of negative reinforcement? a. marty knocks over his mother's prize fern so she gives him a time out. b. gwen mows the lawn and her dad takes her out for ice cream. c. tara takes an aspirin, and her headache begins to go away. d. peter comes in late from his lunch and is fired from his job.
Answers: 1
image
Advanced Placement (AP), 25.06.2019 23:00, andrejr0330jr
For which plan or plans. is knowing the withdrawal restrictions important ?
Answers: 3
image
Advanced Placement (AP), 26.06.2019 05:40, Arealbot
Ineed an answer for this one (number 8)
Answers: 2
Do you know the correct answer?
Me write this code!
starting small
to start, we're going to simulate flipping a coin 1...

Questions in other subjects: