Search
 
SCRIPT & CODE EXAMPLE
 

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}")
Comment

PREVIOUS NEXT
Code Example
Python :: python transpose list 
Python :: django form datepicker 
Python :: identify prime numbers python 
Python :: remover espaços string python 
Python :: for each value in column pandas 
Python :: py pause script 
Python :: jupyter notebook check memory usage 
Python :: python change base function 
Python :: how to print hello in python 
Python :: how to make python open a link 
Python :: python version command notebook 
Python :: longest substring without repeating characters python 
Python :: check if coroutine python 
Python :: argparse example python pyimagesearch 
Python :: Writing Bytes to a File in python 
Python :: add jupyter environment 
Python :: python remove duplicates from list 
Python :: The path python2 (from --python=python2) does not exist 
Python :: python create and show screenshot 
Python :: matplotlib create histogram edge color 
Python :: pygame hide cursor 
Python :: read tsv file column 
Python :: dice roller python 
Python :: check pip installed packages inside virtualenv 
Python :: django password change view 
Python :: Make A Snake Game Using Python and Pygame 
Python :: how to use enumerate instead of range and len 
Python :: how to make a crosshair in python 
Python :: get_terminal_sizee python 
Python :: error bar plot python 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =