This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Rock, Paper, Scissors
#1
Code:
# Python Rock, Paper, Scissors
#4/7/2018
#name

print("******************************")
print(" Python Rock, Paper, Scissors")
print("******************************")
print("\n\n")

import random
player_chosen_item = ''
computer_chosen_int = random.randint(1,3)
computer_chosen_item = ''
if computer_chosen_int == 1:
    computer_chosen_item = 'rock'
elif computer_chosen_int == 2:
    computer_chosen_item = 'paper'
else:# computer_chosen_int == 3:
    computer_chosen_item = 'scissors'

player_chosen_item = str(input("your pick"))

if player_chosen_item == computer_chosen_item:
    print('draw')
elif player_chosen_item == 'rock' and computer_chosen_item == 'scissors':
    print('player wins')
elif player_chosen_item == 'rock' and computer_chosen_item == 'paper':
    print('computer wins')
elif player_chosen_item == 'rock' and computer_chosen_item == 'scissors':
    print('player wins')
elif player_chosen_item == 'rock' and computer_chosen_item == 'paper':
    print('computer wins')
elif player_chosen_item == 'paper' and computer_chosen_item == 'rock':
    print('player wins')
elif player_chosen_item == 'paper' and computer_chosen_item == 'scissors':
    print('computer wins')

elif player_chosen_item == 'scissors' and computer_chosen_item == 'rock':
    print('computer wins')
elif player_chosen_item == 'scissors' and computer_chosen_item == 'paper':
    print('player wins')
print("computer picked:" + computer_chosen_item)
Disclaimer: Don't be misguided looking at my usergroup and assume whatever I say is official. When I speak in community I am just a member with personal opinions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)
www.000webhost.com