RSS

Tag Archives: Paper

Rock Paper Scissors Lizard Spock

The first project in ‘An Introduction to Interactive Programming in Python’, a course I am taking / watching in Coursera is writing code to analyze the results of randomly generated ¬†rock paper scissors lizard Spock games. This game is an adaptation of the standard rock paper scissors with two added items… because it comes from Big Bang Theory, of course it has Spock.

By the way, we often play Rock Paper Scissors at home, but try to come up with new symbols  fairly often.

(Alien populates asteroid, asteroid smashes spaceship, spaceship shoots alien)

(The witch commands the flying monkeys, The flying monkeys carry away Dorothy, Dorothy melts the witch)

The trick for me when writing this code was remembering to import the random module and getting the syntax correct for the if/elif/else statements:

if difference == 1 or difference == 2:
winner = “player”
if difference == 3 or difference == 4:
winner = “computer”
if difference == 0:
winner = “tie”

 
Leave a comment

Posted by on October 17, 2012 in Uncategorized

 

Tags: , , , , , , , , ,