RSS

Rock Paper Scissors Lizard Spock

17 Oct

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: , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: