Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Create function that simulates a coin flip. Each time the function is called,
- it should randomly select either heads or tails and print it out.
- '''
- import random
- #from time import sleep
- def coin_flip():
- flip=random.randint(0,1)
- if flip==1:
- print('heads')
- else: print('tails')
- '''
- While True:
- coin_flip()
- sleep(1)
- '''
- #or:
- for number in range(10):
- coin_flip()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement