Simple console Heads/Tails game written in Python.

# © 2017 TheFlyingKeyboard and released under MIT License
# theflyingkeyboard.net

from random import randint

isPlaying = True
wins = 0
loses = 0
heads = True

while isPlaying:
  print("Wins:", wins, "Loses:", loses)
  
  if randint(0, 100) < 50:
    heads = True;
  else:
    heads = False;
    
  playerInput = input("H for heads, T for tails, E - exit").lower()
    
  if playerInput == "h":
    if(heads):
      wins += 1
    else:
      loses += 1
  elif(playerInput == "t"):
    if(heads):
      loses += 1
    else:
      wins += 1
  elif(playerInput == "e"):
    isPlaying = False

 

Python Console Heads Tails Game
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

This website stores some user agent data. These data are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to opt-out of any future tracking, a cookie will be set up in your browser to remember this choice for one year. I Agree, Deny
504