Coin flip simulation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Coin flip simulation

I have created a coin object https://code.sololearn.com/cw4woujUAbeQ/#py and I want to flip this coin 10times and record the results in a list .And I want to do this 10000 times. Then I want to see how many times I will get consecutive 10 'H' in 10000 try.

7th Jul 2020, 10:29 AM
Baran Aldemir
Baran Aldemir - avatar
3 Answers
+ 2
What issue are you running into then? You can use a loop and specify how many times you want to flip the coin. You can store the heads and tails amount in a variable.
7th Jul 2020, 10:33 AM
coddy
coddy - avatar
+ 2
Baran Aldemir I ran your code a handful of times and got results of 6, 8, 9, 10 and 11. I think it works fairly well 😊 BTW, lines 21 and 22 could be de-indented as they are only useful after all 10 flips.
7th Jul 2020, 11:24 AM
Russ
Russ - avatar
0
Actually this is what I menaged to code https://code.sololearn.com/cFZYTeKfVwP2/#py But I guess something wrong with my code because i think result should be usually close to 9. Coder's Crux
7th Jul 2020, 11:08 AM
Baran Aldemir
Baran Aldemir - avatar