Chapter 5Rock Paper Scissors

Image

In Chapter 4 you learned how to use if statements to create conditions. This is a really important topic, so we’re going to dedicate one more chapter to it, this time creating the game of Rock, Paper, Scissors.

More Strings

We’ve used lots and lots of strings in these past few chapters. As a reminder, strings are simply blocks of text. Code like this should be very familiar by now:

name="Ben"
print(name)

In this example, name is a variable; specifically, it’s a string.

But, now that you’ve seen classes (such as the datetime class in the last chapter), we’ll let you in on a secret: That name string is actually ...

Get Captain Code: Unleash Your Coding Superpower with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.