import random
def coin_game():
toss=""
output=''
Heads=0
coin=int(input("Please enter in a number for how many coins you want to toss"))
for i in range(1,coin+1):
toss=random.choice(['Heads','Tails'])+' '
if toss=='Heads ':
Heads+=1
if i %10==0:
output+=toss
print(output)
output=""
else:
output+=toss
print(output)
t=(Heads/coin)*100
x=print(str(t)+"% number of heads")
print(str(t/Heads)+"% number of tails")
coin_game()
#๐ Hey is there a way to average out the heads and the tails since what I did is not really working
17 messages ยท Page 1 of 1 (latest)
Hey @quiet musk!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
@quiet musk
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Oh averaging out the heads to the tails.
print(str(t/Heads)+"% number of tails") The math in this line is wrong
print(str(100-Heads)+"% number of tails")
you could do this to get the remaining % because it can never be > 100 so just remove the heads from it and then you have the rest leftover
i think
That is the wrong variable ^
Heads is the count not the %of heads. t is the %of heads
oooh oke so then 100-t then in that case
@quiet musk Is this what you need? The % tails should just be 100 - t
ye if i run this on my own machine it gives good answers with print(str(100-t)+"% number of tails")
Yeah thank you guys so much
no problem happy to help
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.