write a program that stimulates flipping a coin 100 times and then displays the total number of heads and total number of tails achieved

5 Years
Discussion Span
Last Post by phorce

score=raw_input("enter your score:") if score=random.randrange(999)+1 print "nothing to brag about" raw_input(\n\nPress the enter key to exit)

Edited by marethamogale: this is an attempt to another question which says write a program that gets a score from the player and rate it based on the following Given a score between 0-999,the program should display the message, "Nothing to brag about"


Your code has hardly anything to do with the task you mentioned in the first post.

Try to program the following procedure in python.

Let's make two variable that will store the number of tails and heads.
Let they be: numtails=0, numheads=0
Loop begins here. Count 100 times.
For each count generate a coin flip, head or tail.
If the coin is head, increase numheads, else increase numtails by one.
Loop ends here.
Print out numheads and numtails.


Because I'm learning Python at the moment, I'm going to give you a start.. Something like this:

import string
import random 

def FlipCoin(): 

    coin = ['heads', 'tails'];

    return random.choice(coin);

def main():

    heads = 0;
    tails = 0;

    for x in range(0, 100):
        print FlipCoin();


I'm sure that you can finish this off. :)

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.