Lesson 3

Introducing Input


The ‘input()’ function takes data from the keyboard, and introduces it into our program as a string. Anything that you put inside of the parenthesis gets printed out as a prompt for the user.

On line 12, we will be setting up an input that will ask for the users name. Add the following code myName= input(“insert your name: “). Make sure to place a space after the semi colon, so that the text does not smush together

On line 13, we will incorporate this input into a print function. Add the following code print(“Hello, my name is ” + myName). Again, make sure to add in spaces where appropriate.

When we run this code, the Terminal window will ask us for an input. After entering our input, it should give us a print statement.

Adding Addtional Inputs


Now that we understand the basics of how to use inputs, we can set up a couple of more

For our game of ‘Madlibs’, we will need an input for each of the following categories:name,noun,adjective,verb, and adverb

These inputs will all be set up using the same code, the only different will be the way we name our variable, and what question the input is going to ask for