- #Assignment 3#Rock Paper Scissors Lizard...

Info icon This preview shows pages 1–2. Sign up to view the full content.

#Assignment 3 #Rock Paper Scissors Lizard Spock (Couldn't Help Myself) #Name: Brittany Wojciehowski import random numberofgames = raw_input("How many games do you want to play?") print "Please type (R)rock, (P)aper, (s)issors, (L)izard, or (S)pock." choice = raw_input("What did you choose?") player_choice = str(choice) def name_to_number(name): if name == "R": name = 0 return name elif name == "S": name = 1 return name elif name == "P": name = 2 return name elif name == "L": name = 3 return name elif name == "s": name = 4 return name def number_to_name(number): if number == 0: number = "Rock" return number elif number == 1: number = "Spock" return number elif number == 2: number = "Paper" return number elif number == 3: number = "Lizard" return number elif number == 4: number = "Scissors" return number try: computer_choice = random.randrange(5)
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: player_number = name_to_number(player_choice) print "Player choice is: " + player_choice print "Computer choice is: " + number_to_name(computer_choice) difference = (int(player_number) - computer_choice) % 5 draws = 0 playerwins = 0 computerwins = 0 if difference in [1, 2]: print "Player wins!" playerwins = playerwins + 1 elif difference == 0: print "Player and computer tie!" draws = draws + 1 else: print "Computer wins!" computerwins = computerwins + 1 print "Wins: " + str(playerwins) + "\n" + "Draws: " + str(draws) + "\n" + "Losses " + str(computerwins) while playerwins + draws + computerwins <= numberofgames: main() except TypeError: print "Sorry, please read the directions and type rock, paper, scissors, spock, or lizard in lowercase."...
View Full Document

  • Fall '15
  • Rock-paper-scissors, playerWins, Return number, computerwins

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern