Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python rock paper scissor

import random
# 1 is paper 2 is scissor 3 is rock
nuber = [1, 2, 3]
var = input('rock paper or scissor/ type like r/p/s: ').lower()
number = random.choice(nuber)

user = 0
computer = 0

if var == 'r':

    if number == 1:
        print('you lose')
        computer += 1
    elif number == 2:
        print('you win')
        user += 1
    elif number == 3:
        print('its a tie')
        user += 1
        computer +=1

elif var == 'p':

    if number == 1:
        print('its a tie')
        user += 1
        computer += 1
    elif number == 2:
        print('you lose')
        computer += 1
    elif number == 3:
        print('you won')
        user += 1

elif var == 's':
    
    if number == 1:
        print('you win')
    elif number == 2:
        print('its a tie')
    elif number == 3:
        print('you lose')
        
print(f"ur score {user}")
print(f"comp score {computer}")
 
PREVIOUS NEXT
Tagged: #python #rock #paper #scissor
ADD COMMENT
Topic
Name
6+8 =