1.1.2 Getting User Input

Video

1.1.2 Getting User Input

In this video, you'll learn how to get user input, which makes every program much more interesting! Watch the video below, then try it yourself in the editor.

Try It Yourself

Start with this simple program in the editor below:

name = input("What's your name? ")
print("Hello", name)

Steps to follow:

  1. Type the code above into the editor (or start with just print("Hello world") to test)
  2. Click Run - When you run code with input(), a prompt will appear asking for your input
  3. Enter your name in the prompt dialog
  4. See the output - Your program will greet you by name!

Next steps:

  • Try asking for multiple inputs (color, food, etc.)
  • Use those inputs to create a story
  • Build your own Mad Lib!

Note: The video shows creating a new file in Spyder, but you're using the browser editor. Just type your code directly in the editor below - no need to create a file!

Loading Python environment...