RPS

import random computer_choice = random.randint(1,3) stage.set_background("fall") cplayer = codesters.Sprite("athlete1") cplayer.go_to(0,-100) cplayer.say("Lets play rock, paper, scissors",3,"MediumSlateBlue",28,"Arial Black") cplayer.say("I've made my choice.",1,"MediumSlateBlue",28,"Arial Black") choice = cplayer.ask("Choose either Rock, Paper, or Scissors?") choice = choice.lower() cplayer.say("You chose " + choice + ".",1,"MediumSlateBlue",28,"Arial Black") if computer_choice == 1: computer_choice = "rock" elif computer_choice == 2: computer_choice = "paper" elif computer_choice == 3: computer_choice = "scissors" cplayer.say("I chose " + computer_choice + ".",1,"MediumSlateBlue",28,"Arial Black") if choice == computer_choice: cplayer.say("It's a tie. Great minds think alike.",3,"MediumSlateBlue",28,"Arial Black") elif choice == "rock" and computer_choice =="scissors": cplayer.say("You win! Rock bashes scissors.",3,"MediumSlateBlue",28,"Arial Black") elif choice == "paper" and computer_choice == "rock": cplayer.say("You win! Paper covers rock.",3,"MediumSlateBlue",28,"Arial Black") elif choice == "scissors" and computer_choice == "paper": cplayer.say("You win! Scissors cuts paper.",3,"MediumSlateBlue",28,"Arial Black") else: cplayer.say("You lose. Better luck next time.",3,"MediumSlateBlue",28,"Arial Black")
  • Run Code
  • Show Console
  • Codesters How To (opens in a new tab)