Page

# Assignment 2.1 - Answer

## Assignment 2.1 - Answer

```
# Heads or tails, 50 times will tell
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")
number_of_heads += 1
else:
print("Tails")
number_of_tails += 1
print ("'Heads' came " + str(number_of_heads) + " times and 'Tails' came " + str(number_of_tails) + " times.")
if number_of_heads > number_of_tails:
print ("The Grand winner is 'Heads'.")
elif number_of_heads < number_of_tails:
print ("The Grand winner is 'Tails'.")
else:
print ("It is a tie, nobody wins, try again.")
```

Last modified: Thursday, 18 May 2017, 7:33 PM