divider

Objective

Your task is to create a program that lets the user play a game of Heads or Tails. Along with the core game, your program should keep track of wins and losses, and ask the user if they want to play again.

Skills to Practice

  • icon Generating random numbers
  • icon Iteration with loops
  • icon Making decisions with if statements
divider

Tasks

  • icon Create a new project named application-2-5
  • icon Complete the following tasks:
    • icon Create a program where the user can play Heads or Tails by guessing the outcome of a coin flip.
    • icon Keep track of the number of games won and lost by the user.
    • icon After each game, ask the user if they want to play again. If they choose to continue, repeat the game. If not, end the program and display the total wins and losses.
divider

Sample Output

Sample Output
Welcome to Heads or Tails!
Guess the outcome (heads/tails): heads [Enter]
It's heads! You win!
Wins: 1 | Losses: 0
Do you want to play again? (yes/no): yes [Enter]
Guess the outcome (heads/tails): tails [Enter]
It's heads! You lose.
Wins: 1 | Losses: 1
Do you want to play again? (yes/no): no [Enter]
Thanks for playing! Final score: Wins: 1 | Losses: 1

Begin Challenge