i have to write a program that simulates the flipping of a coin.

1. the function should ask the user how many times the coin should be flipped

2. the program should display the poportion of times that the head and tails appeared. (for example if the user enters 10 and 53 of the them are heads. the program should output 'heads' 0.53, 'Tails' 0.47.

3. the program should have four functions main,input,flip,display, and they should call each other to display the answer

this is my code at the moment in time
import random
def main():
userInput = getInputs()

def inputs():
userInput = int(raw_input("Number of times to flip the coin: ")

def flips(userInput):
heads = 0
tails = 0
counter = 0
while counter < userInputs:
if randon.randrange(0,2)
heads += 1
if heads > 0
print displayResluts()

def results():
return simlatefilps()

I am wonder if I am writing the code in the right format. Can someone help me find a solution too if possible.

8 Years
Discussion Span
Last Post by vegaseat

The first two posts found in a search of this forum, after your post which is the first/latest, have working solutions that you should be able to adapt.


Check out PEP8 on correct python style. As far as help it looks like you have most of what you need. I urge you to figure the rest out on your own, its the best way to learn. However if you have a specific question on how to do something feel free to ask. Also please edit your post and use code tags.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.