HOME | DD

#program #programming #python
Published: 2022-12-24 20:04:32 +0000 UTC; Views: 159; Favourites: 0; Downloads: 0
Redirect to original
Description
I decided a bit ago to make a coin flip game entirely in python. It was something simple so why not.--CODE--
import random
PlayerScore = 0
ComputerScore = 0
CoinSide = random.randint(1, 2)
PlayerGuess = input("What do you think coin will land on: ")
while PlayerGuess != "ZZ":
print("You guessed " + PlayerGuess)
if PlayerGuess == "Heads" and CoinSide == 1:
#The win statement
print("Correct")
#Now lets reset the game and add to the score
PlayerScore += 1
CoinSide = random.randint(1, 2)
PlayerGuess = input("What do you think coin will land on: ")
elif PlayerGuess == "Tails" and CoinSide == 2:
#The win statement
print("Correct")
#Now lets reset the game and add to the score
PlayerScore += 1
CoinSide = random.randint(1, 2)
PlayerGuess = input("What do you think coin will land on: ")
else:
#The lose statement
print("Incorrect")
#Now lets reset the game and add to the score
ComputerScore += 1
CoinSide = random.randint(1, 2)
PlayerGuess = input("What do you think coin will land on: ")
print("Player Score: " + str(PlayerScore))
print("Computer Score: " + str(ComputerScore))
Related content
Comments: 2
NaturalBornSkiller [2022-12-24 20:49:12 +0000 UTC]
👍: 0 ⏩: 1
DigitalDevilProgram In reply to NaturalBornSkiller [2023-01-05 23:21:12 +0000 UTC]
👍: 0 ⏩: 0