This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Learn some programming basics


Using Wing IDE, you'll learn some of the programming basics that you'll need in order to build your game.

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!

Task Discussion


  • Thug said:

    123 = raw_input("Tell me your name and press ENTER ")

    print "Once I had a cat named " + 123

    on Dec. 3, 2013, 12:24 p.m.
  • Thug said:

    number = raw_input("Tell me your name and press ENTER ")

    print "Once I had a dog named " + number

    on Dec. 3, 2013, 12:23 p.m.
  • Fer said:

    nombre = raw_input("Tell me your name and press ENTER ")

    print "Once I had a cat named " + nombre

    on Nov. 7, 2013, 4:41 a.m.
  • Fer said:

    nombre = str(raw_input("Tell me your name, and click ENTER "))
    print "Once I had a cat named " + nombre

     

    on Nov. 7, 2013, 4:40 a.m.
  • Fer said:

    nombre = str(raw_input("Tell me your name, and click ENTER "))
    print "Once I had a cat named " + nombre
     

    on Nov. 7, 2013, 4:39 a.m.
  • Fer said:

    nombre = str(raw_input("Tell me your name, and click ENTER "))
    print "Once I had a cat named " + nombre
     

    on Nov. 7, 2013, 4:38 a.m.
  • v4lent1na said:

    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)

    on Sept. 18, 2013, 12:30 p.m.
  • Joseortiz87 said:

     

    first_name = input("Tell me your name, and click enter. ")
    print("Cool, now let's start the game " + first_name)
     
    with python 3.3
    on May 7, 2013, 12:31 p.m.
  • Wouter Tebbens said:

    first_name = raw_input("Tell me your name, and click enter. ")

    print "Welcome at the game, " + first_name + "!"

    on March 26, 2013, 5:29 a.m.
  • Mars83 said:

    first_name = raw_input("Tell me your name, and click enter.")
    
    print "Nice goal, " + first_name + "!"

    on Sept. 11, 2012, 3:22 p.m.
  • saravanan said:

    first_name=input("Tell me your name, and click enter. ")
    
    print("Thank You for providing information",first_name)
    
    
    on Sept. 10, 2012, 2:52 a.m.
  • amryfitra said:

     

    note : in 3.2 raw_input changeto input
     
    __author__ = 'amryfitra'
     
     
    firstname = input("Please give ur name and press enter : ")
     
    print("Thanks your firstname is",firstname)
    on Aug. 21, 2012, 10 a.m.
  • Anonym said:

     

    first_name = raw_input("What's your name?.")
    
    print "Oh, hi "+ first_name +"!"
    on July 15, 2012, 10:04 a.m.
  • ionut.vlasin said:

    first_name = raw_input("Tell me your name, and click enter. ")
    print first_name
    print "Thanks! Your name is " + first_name

    on July 11, 2012, 3:38 a.m.
  • Francesco Malagrino' said:

     

    first_name = raw_input("Welcome !!! ")
    print "Thanks! Your name is " +  first_name.capitalize(), "Enjoy!!!"
    on May 9, 2012, 5:32 a.m.
  • Lisa said:

    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."

    on March 13, 2012, 5:48 p.m.
  • dvdjaco said:

    first_name = raw_input("Tell me your name, and click enter. ")
    
    print "Thanks, " + first_name + ", now I know your name"

    on Feb. 21, 2012, 7 p.m.
  • Justin Ward said:

     

    first_name = raw_input("Tell me your name, and click enter. ")
    print "Hi " + first_name + ", I am Holly the ship's computer."
    on Feb. 17, 2012, 7:49 p.m.
  • gnuisance said:

    first_name = raw_input('What did you say your name was? ')
    print 'Sorry', first_name.capitalize(), "I'm so bad with names."

    on Jan. 30, 2012, 6:50 p.m.