import random
# Assigning the variables
i = 1
h = 1
t = 2
lit = []
lih = []
# Starting the loop
while 101 > i:
# Random function to select 1,2 to represent heads and tails.
data = random.randint(h,t)
print data
i = i + 1
data = int(data)
if data == 1:
lih.append("1")
if data == 2:
lit.append("2")
e = len(lit)
e = str(e)
f = len(lih)
f = str(f)
print 'You flipped tails ' + e + ' ' + 'times ' + 'and ' + 'You flipped heads ' + f + ' times'
raw_input()
This is just an example of what you can do with very simple functions, and just a few lines of code.
No comments:
Post a Comment