Support Forums

Full Version: Flip a Coin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
import random
raw_input('Press Enter To Flip The Coin')
b = '   @@@@@   ','  @     @  ',' @  O O  @ '  ,' @  ___  @ ','  @     @  ','   @@@@@   '
a = '   @@@@@   ','  @|/ \|@  ',' @ |/ \| @ '  ,' @ |/ \| @ ','  @|/ \|@  ','   @@@@@   '
c = [a,b]
print "\n".join(random.choice(c))

EDIT:
Now you can choose how high to throw the coin, and this version gives the illusion the coin is spinning.

Code:
import random,os,time
os.system("clear")
print '1) Low'
print '2) High'
z = int(raw_input('How high do you want to flip the coin: '))
if z == 1:
    qz = 2
if z ==2:
    qz = 5
x = 0
x = x + 1
time.sleep(0.2)
b = '   @@@@@   ','  @     @  ',' @  O O  @ '  ,' @  ___  @ ','  @     @  ','   @@@@@   '
q = '    |','    |','    |','    |','    |','    |'
a = '   @@@@@   ','  @|/ \|@  ',' @ |/ \| @ '  ,' @ |/ \| @ ','  @|/ \|@  ','   @@@@@   '
c = [a,b]
os.system("clear")
for x in xrange(qz):
    os.system("clear")
    print "\n".join(q)
    time.sleep(0.2)    
    os.system("clear")
    time.sleep(0.2)
    print "\n".join(random.choice(c))
    time.sleep(0.2)
I like this one its fun.