+ 6
CHALLENGE FOR ALL SOLOLEARNERS(PYTHON)
I challenged myself to make a program that flips a coin a hundred times and shows if its head or tails for each time it flips but I have no idea how to go about it. Already started but my code is a mess.
7 ответов
+ 11
Idk, Python isn't my main. By flip, do you mean flip it to the other side? Something like:
coin = True
for i in range(0, 100):
coin = not coin
print ('heads' if coin else 'tails')
or is it a coin toss which results in a 'random' face?
+ 4
Oh thanks.
+ 4
A little Python code here, I hope it helps...
https://code.sololearn.com/cDL25CD4aVa6/#py
+ 1
from random import randrange
for i in range(100):
print('head' if randrange(2) else 'tail')
you can also create the list of results that way :
l = [randrange(2) for i in range(100)]
+ 1
eh, there was a challenge as it here https://www.sololearn.com/Discuss/664184/ and here my code https://code.sololearn.com/WEnDsYSBDN6z/?ref=app