Professional Documents
Culture Documents
Coin - Flip Python Code
Coin - Flip Python Code
Coin - Flip Python Code
This code functions by importing the 'random' module, which enables random number
generation. It then uses the 'randint' function to generate a random integer between 0 and 1,
inclusive. If the generated number is greater than 0.5, indicating a probability of approximately
50%, the program prints 'Heads'; otherwise, it prints 'Tails'. This script effectively simulates the
outcome of flipping a fair coin, providing either 'Heads' or 'Tails' as the result of the coin flip.