Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Rock, Paper, Scissors With Python: A Command Line Game (Overview)

Game programming is a great way to learn how to program. You use many tools that you’ll see in the real world, plus you get to play a game to test your results! An ideal game to start your Python game programming journey is rock paper scissors.

In this course, you’ll learn how to:

  • Code your own rock paper scissors game
  • Take in user input with input()
  • Play several games in a row using a while loop
  • Clean up your code with Enum objects and functions
  • Define more complex rules with a dictionary

Download

Sample Code (.zip)

6.7 KB

Download

Course Slides (.pdf)

2.7 MB

00:00 Welcome to Rock, Paper, Scissors: A Command Line Game. My name is Chris and I will be your guide. In this course, you will learn about writing a command line rock paper scissors game, handling user input, looping for multiple games in a row, creating functions to group code, using dictionaries to store rules, and replacing constants with Enum objects.

00:28 A quick note about versions. All code in this course was tested using Python 3.9. There isn’t much in here that is version specific. Any interpreter starting with Python 3.4 will work fine.

00:41 A common path to becoming interested in programming is through the love of video games. This makes writing your own game a logical place to start when you’re learning to code. Graphical games have extra things to learn because you’re dealing with drawing to the screen. Command line text-based games are the perfect entryway. You get to write some code, play your game, but not be buried under bit blitting and vector math.

01:05 If you’ve never played before, rock paper scissors is a two-person game often used to quickly decide who goes first in a board game, who gets the first slice of pie, or any other simple decision.

01:16 Each person counts to three, shakes their fist, and then makes a symbol. This is called “throwing.” The symbols make a three-way cycle, each symbol beating one other.

01:27 The choices are: Make a fist to show a rock, rock smashes scissors. Make a palm to show paper, paper covers rock. Or show two fingers—careful where you’re pointing those in Britain—to make the scissors. Scissors cut paper.

01:46 To build a text-based version of this game, you’ll need to take user input, randomly choose a computer’s throw, and compare who won.

01:57 Next up, your first stab at some code. See what I did there? Scissors joke for the win. Well, unless, of course, you chose rock.

Become a Member to join the conversation.