teromakotero

Coin flip

May 5th, 2019
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. '''
  2. Create function that simulates a coin flip. Each time the function is called, it should randomly select
  3. either heads or tails and print it out.
  4. '''
  5. import random
  6.  
  7. def coin_flip():
  8.     heads_tails = random.randint(0,1)
  9.     if(heads_tails == 0):
  10.         print("heads")
  11.     else:
  12.         print("tails")
  13.        
  14. coin_flip()
Advertisement
Add Comment
Please, Sign In to add comment