CM 6.4 MRG Conditionals

3621 days ago by calcpage123

#10) rock paper scissors game! peep = choice('rps') comp = choice('rps') peepScore = 0 compScore = 0 numTies = 0 while peep != 'q': if peep == 'r': if comp == 'r': print "rock vs rock is a tie!" numTies += 1 if comp == 'p': print "rock vs paper, comp wins!!" compScore += 1 if comp == 's': print "rock vs scissors, peep wins!!!" peepScore += 1 if peep == 'p': if comp == 'r': print "paper vs rock, peep wins!!!" peepScore += 1 if comp == 'p': print "paper vs paper is a tie!" numTies += 1 if comp == 's': print "paper vs scissors, comp wins!!" compScore += 1 if peep == 's': if comp == 'r': print "scissors vs rock, comp wins!!" compScore += 1 if comp == 'p': print "scissors vs paper, peep wins!!!" peepScore += 1 if comp == 's': print "scissors vs scissors is a tie!" numTies += 1 peep = choice('rpsq') comp = choice('rps') print "peep score = " + str(peepScore) print "comp score = " + str(compScore) print "number of ties = " + str(numTies) 
       
rock vs rock is a tie!
scissors vs paper, peep wins!!!
paper vs paper is a tie!
paper vs scissors, comp wins!!
scissors vs paper, peep wins!!!
rock vs rock is a tie!
rock vs rock is a tie!
peep score = 2
comp score = 1
number of ties = 4
rock vs rock is a tie!
scissors vs paper, peep wins!!!
paper vs paper is a tie!
paper vs scissors, comp wins!!
scissors vs paper, peep wins!!!
rock vs rock is a tie!
rock vs rock is a tie!
peep score = 2
comp score = 1
number of ties = 4