Assignment
Assignment 2.1
Assignment 2.1
Completion requirements
Opened: Saturday, 13 May 2017, 9:55 AM
Coin flip tosser
- Create a program that will print a random 0 or 1.
- Instead of 0 or 1, print heads or tails. Do this using if statements.
- Add a loop so that the program does this 50 times.
- Create a running total for the number of heads flipped, and the number of tails.
A starting example - it is not the complete code. There inshelp inside the comments.
Search for random command here
import random
#number_of_heads = 0
#number_of_tails = 0
#for i in range(50):
x = random.randint(0,1)
#print(x)
if x == 0:
print("head")
else:
print("tails")