Thug said:
123 = raw_input("Tell me your name and press ENTER ")
print "Once I had a cat named " + 123
This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.
In order to build your game, you'll need to know a few programming basics. Let's learn about them now. The three things you'll need to know are:
1. How to ask a player for information
2. How to store that information
3. How to write a sentence using the player's information
Let's start with #1: Asking a player for information.
- Open Wing IDE, and in the top-left corner, type the following:
first_name = raw_input("Tell me your name, and click enter. ")
- Find the green "play" arrow. Click it. (This starts your game.)
- In the bottom-right corner, play your game.
There! You just figured out how to ask a player for information.
Now, let's figure out how we can store that information. The good news is that we're halfway done. Because you replied with your name, it has been stored as the variable "first_name". You can imagine that we have a jar called "first_name" and your name is inside it. Now, let's figure out how we can tell the computer to tell us what's in the "first_name" jar.
- In the top-left corner of Wing IDE, keep the line you just typed. Click "enter" so that you're on a new line. Type the following:
print first_name
- Click the green "play" arrow again. Play your game in the lower-right corner. Note what happens.
Now, we're on to Step 3: displaying a sentence that uses the player's information.
Instead of just displaying your name when you play the game, imagine we wanted the computer to say, "Thanks! Your name is [your name here]." How would we do that?
- Go back to Wing IDE. On the line where you have the word "print", we're going to add some words. Change that line so that it looks like this:
print "Thanks! Your name is " + first_name
- Click the green "play" arrow. Play your game in the lower-right corner. Note what happens.
- Change the sentence you are "printing". Make it more fun! Copy and paste your code into the discussion below.
You now know the programming basics you'll need in order to build your first game!
123 = raw_input("Tell me your name and press ENTER ")
print "Once I had a cat named " + 123
number = raw_input("Tell me your name and press ENTER ")
print "Once I had a dog named " + number
nombre = raw_input("Tell me your name and press ENTER ")
print "Once I had a cat named " + nombre
nombre = str(raw_input("Tell me your name, and click ENTER "))
print "Once I had a cat named " + nombre
nombre = str(raw_input("Tell me your name, and click ENTER "))
print "Once I had a cat named " + nombre
nombre = str(raw_input("Tell me your name, and click ENTER "))
print "Once I had a cat named " + nombre
first_name = raw_input("Tell me your name, and click enter. ")
print "You're dumb if you don't remember your name, " + first_name
(with Python 2x)
first_name = raw_input("Tell me your name, and click enter. ")
print "Welcome at the game, " + first_name + "!"
first_name = raw_input("Tell me your name, and click enter.") print "Nice goal, " + first_name + "!"
first_name=input("Tell me your name, and click enter. ") print("Thank You for providing information",first_name)
first_name = raw_input("What's your name?.") print "Oh, hi "+ first_name +"!"
first_name = raw_input("Tell me your name, and click enter. ")
print first_name
print "Thanks! Your name is " + first_name
first_name = raw_input("Welcome! What's your name? Type it and click enter. ")
print "Hello " + first_name + ". You humans are lucky. I don't have a name."
first_name = raw_input("Tell me your name, and click enter. ") print "Thanks, " + first_name + ", now I know your name"
first_name = raw_input('What did you say your name was? ')
print 'Sorry', first_name.capitalize(), "I'm so bad with names."