Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. '''
  2. Create function that simulates a coin flip. Each time the function is called,
  3. it should randomly select either heads or tails and print it out.
  4. '''
  5. import random
  6. #from time import sleep
  7. def coin_flip():
  8.     flip=random.randint(0,1)
  9.     if flip==1:
  10.         print('heads')
  11.     else: print('tails')
  12.    
  13. '''
  14. While True:
  15.    coin_flip()
  16.    sleep(1)
  17. '''
  18. #or:
  19. for number in range(10):
  20.     coin_flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement