1.11M Members

branching,while loops,and program planning

 
0
 

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

 
0
 

Where are your efforts to solve the assignment ?

 
0
 

Give us the code you have written so far and the problems you had.

 
0
 

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)

 
0
 

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.

 
0
 

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();

main();

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

Question Answered as of 9 Months Ago by vegaseat, slate, Gribouillis and 1 other
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article