🪙

Coin Flip

Python82 lines· This is a Python program used to simulate a coin toss, in which a user is asked to pick a side (heads or tails), and the program selects a result a…
Original project by @pranavdasan — view source on GitHub
Ready when you are
README· what to build

Coin Flip

This is a Python program used to simulate a coin toss, in which a user is asked to pick a side (heads or tails), and the program selects a result at random between the two options. If the user's choice matches the result, they win the coin toss.

Example

Pick a side for the coin toss (heads/tails): heads
You got... tails
OOF. Better luck next time.
Wanna play again? (yes/no): yes
Pick a side for the coin toss (heads/tails): tails
You got... tails
Nice, you won the coin toss!!
Wanna play again? (yes/no): no

How to Play

  1. When the program is initiated, you will be prompted to choose either "heads" or "tails".
  2. The program will then determine the winning result by random chance, and display it.
  3. If your choice matches the result, you win the coin toss. If not, you'll receive a "OOF" message to indicate a loss.
  4. After the end of each round, you will be asked if you want to play again. Type "yes" to continue playing or "no" to exit the program.

Enjoy!

coin-flip.py· Python 3.x
53 lines
Console· terminal