import random as r
#the possible moves in rock paper scissors
RPS = [ "ROCK" , "PAPER" , "SCISSORS" ]
def main( ) :
comp = computerMove( )
player = playerMove( )
winner, tie = calcWinner( comp, player)
dispWinner( winner, tie)
#the move made by the computer
def computerMove( ) :
return "ROCK"
#move made by the user
def playerMove( ) :
player = ""
while not player in RPS:
player = input ( "Choose your weapon(rock, paper, or scissors: " ) .upper ( )
## print(player)
return player
#determining a winner
def calcWinner( comp, player) :
print ( "The computer chooses {0}." .format ( comp) )
winner = None
tie = False
## if theres a tie
if player == comp:
print ( "No winner.... Restarting....\n " )
main( )
tie = True
## if the user wins
elif ( ( comp == "ROCK" ) and ( player == "PAPER" ) ) or ( ( comp== "PAPER" ) and ( player == "SCISSORS" ) ) or ( ( comp== "SCISSORS" ) and ( player == "ROCK" ) ) :
winner = True
## if computer won
else :
winner = False
return winner, tie
def dispWinner( winner, tie) :
if tie == True :
print ( "TIE!!!!" )
elif winner == True :
print ( "You beat the computer!" )
elif winner == False :
print ( "The computer beat you!" )
main( )
aW1wb3J0IHJhbmRvbSBhcyByCgojdGhlIHBvc3NpYmxlIG1vdmVzIGluIHJvY2sgcGFwZXIgc2Npc3NvcnMKUlBTID0gWyJST0NLIiwgIlBBUEVSIiwgIlNDSVNTT1JTIl0KCmRlZiBtYWluKCk6CiAgICBjb21wID0gY29tcHV0ZXJNb3ZlKCkKICAgIHBsYXllciA9IHBsYXllck1vdmUoKQogICAgd2lubmVyLCB0aWUgPSBjYWxjV2lubmVyKGNvbXAsIHBsYXllcikKICAgIGRpc3BXaW5uZXIod2lubmVyLCB0aWUpCgojdGhlIG1vdmUgbWFkZSBieSB0aGUgY29tcHV0ZXIKZGVmIGNvbXB1dGVyTW92ZSgpOgoJcmV0dXJuICJST0NLIgoKI21vdmUgbWFkZSBieSB0aGUgdXNlcgpkZWYgcGxheWVyTW92ZSgpOgogICAgcGxheWVyID0gIiIKICAgIHdoaWxlIG5vdCBwbGF5ZXIgaW4gUlBTOgogICAgICAgICAgICBwbG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F0IHlvdSEiKQoKCm1haW4oKQo=
stdout
Choose your weapon(rock, paper, or scissors: The computer chooses ROCK.
No winner.... Restarting....
Choose your weapon(rock, paper, or scissors:
stderr
Traceback (most recent call last):
File "./prog.py", line 54, in <module>
File "./prog.py", line 9, in main
File "./prog.py", line 33, in calcWinner
File "./prog.py", line 8, in main
File "./prog.py", line 20, in playerMove
EOFError: EOF when reading a line