Answers for "rock paper scissors ai self learning python"

1

rock paper scissors python

import random
while True:
    choices = ["rock","paper","scissors"]

    Computer = random.choice(choices)
    Player = None

    
    while Player not in choices:
       Player = input("Rock,Paper or Scissors?:").lower()

    if Player == Computer:
       print("computer:", Computer)
       print("Player:", Player)
       print("Draw!")

    elif Player == "rock":
        if Computer == "paper":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU WIN !:D")
        if Computer == "scissors":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU LOSE:(")

    elif Player == "paper":
        if Computer == "rock":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU WIN! :D")
        if Computer == "scissors":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU LOSE:(")

    elif Player == "scissors":
        if Computer == "paper":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU WIN! :D")
        if Computer == "rock":
            print("computer:", Computer)
            print("Player:", Player)
            print("YOU LOSE:(")
  
    Play_again = input("Play again?(Yes/No):").lower()
    
    if Play_again != "Yes".lower():
       break

print("Bye!")
Posted by: Guest on August-07-2021
0

python rock paper scissors

import random

game_list = ['Rock', 'Paper', 'Scissors']
computer = c = 0
command = p = 0

print("Score: Computer" + str(c) + " Player " + str(p))

# the loop
run = True
while run:
    computer_choice = random.choice(game_list)
    command = input("Rock, Paper, Scissors or Quit: ")

    if command == computer_choice:
        print("Tie")
    elif command == 'Rock':
        if computer_choice == 'Scissors':
            print("Player won!")
            p += 1
        else:
            print("Computer won!")
            c += 1
    elif command == 'Paper':
        if command == 'Rock':
            print("Player won!")
            p += 1
        else:
            print("Computer won!")
            c += 1
    elif command == 'Scissors':
        if computer_choice == 'Paper':
            print("Player won!")
            p += 1
        else:
            print("Computer won!")
            c += 1
    elif command == 'Quit':
        break
    else:
        print("Wrong command! ")

    print("Player: " + command)
    print("Computer: " + computer_choice)
    print("")
    print("Score: Computer " + str(c) + " Player " + str(p))
    print("")
Posted by: Guest on October-07-2020

Code answers related to "rock paper scissors ai self learning python"

Python Answers by Framework

Browse Popular Code Answers by Language