python flip a coin

Solutions on MaxInterview for python flip a coin by the best coders in the world

showing results for - "python flip a coin"
Ariadna
04 Feb 2017
1import random
2
3result = random.choice(["Heads","Tails"])
Angela
10 Jun 2020
1# Import the RANDOM library.
2import random as RANDOM # the 'as RANDOM' part could be optionial, 
3# it's just choosing a name for the import.
4
5def flip():
6  flipped = RANDOM.choice('Heads','Tails')
7  print(f'You flipped {flipped}')
Isaac
16 Apr 2017
1import random
2result = random.choice(["Heads","Tails"])