Answers for "how to code rock paper scissors"

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
1

rock paper scissors

import random

print('Get ready for rock,paper,scissors')
user = input('Enter your element:')
element = ['I choose Rock', 'I choose Paper', 'I choose Scissors']
AI = random.choice(element)
print(AI)
# Ties
if AI == str('I choose Rock') and user == str('rock'):
    print('Its a tie')
if AI == str('I choose Paper') and user == str('paper'):
    print('Its a tie')
if AI == str('I choose Scissors') and user == str('scissors'):
    print('Its a tie')
# Rock AI
if AI == str('I choose Rock') and user == str('paper'):
    print('You won')
if AI == str('I choose Rock') and user == str('scissors'):
    print('You lost')
# Rock user
if AI == str('I choose Paper') and user == str('rock'):
    print('You lost')
if AI == str('I choose Scissors') and user == str('rock'):
    print('You won')
# Paper AI
if AI == str('I choose Paper') and user == str('rock'):
    print('You lost')
if AI == str('I choose Paper') and user == str('scissors'):
    print('You won')
# Paper user
if AI == str('I choose Rock') and user == str('paper'):
    print('You won')
if AI == str('I choose Scissors') and user == str('paper'):
    print('You lost')
# Scissors AI
if AI == str('I choose Scissors') and user == str('paper'):
    print('You lost')
if AI == str('I choose Scissors') and user == str('rock'):
    print('You won')
# Scissors user
if AI == str('I choose Paper') and user == str('scissors'):
    print('You won')
if AI == str('I choose Rock') and user == str('scissors'):
    print('You lost')


def restartgame():
    print('Get ready for rock,paper,scissors')
    user = input('Enter your element:')
    element = ['I choose Rock', 'I choose Paper', 'I choose Scissors']
    AI = random.choice(element)
    print(AI)
    # Ties
    if AI == str('I choose Rock') and user == str('rock'):
        print('Its a tie')
    if AI == str('I choose Paper') and user == str('paper'):
        print('Its a tie')
    if AI == str('I choose Scissors') and user == str('scissors'):
        print('Its a tie')
    # Rock AI
    if AI == str('I choose Rock') and user == str('paper'):
        print('You won')
    if AI == str('I choose Rock') and user == str('scissors'):
        print('You lost')
    # Rock user
    if AI == str('I choose Paper') and user == str('rock'):
        print('You lost')
    if AI == str('I choose Scissors') and user == str('rock'):
        print('You won')
    # Paper AI
    if AI == str('I choose Paper') and user == str('rock'):
        print('You lost')
    if AI == str('I choose Paper') and user == str('scissors'):
        print('You won')
    # Paper user
    if AI == str('I choose Rock') and user == str('paper'):
        print('You won')
    if AI == str('I choose Scissors') and user == str('paper'):
        print('You lost')
    # Scissors AI
    if AI == str('I choose Scissors') and user == str('paper'):
        print('You lost')
    if AI == str('I choose Scissors') and user == str('rock'):
        print('You won')
    # Scissors user
    if AI == str('I choose Paper') and user == str('scissors'):
        print('You won')
    if AI == str('I choose Rock') and user == str('scissors'):
        print('You lost')
    again = input('Would you like to play again')
    if again == str('yes'):
        restartgame()
    if again == str('no'):
        raise SystemExit(0)


again = input('Would you like to play again')
if again == str('yes'):
    restartgame()
if again == str('no'):
    raise SystemExit(0)
Posted by: Guest on November-09-2020

Code answers related to "how to code rock paper scissors"

Python Answers by Framework

Browse Popular Code Answers by Language