Getting input from the user
[vocab] user input
Published in
2 min readJan 17, 2018
→ Lab Assignment: “Madlib (User Inputs)” on repl.it
[python learned]
input()
function.capitalize()
method
[demo]
- valentine.py (If you’d like to run this yourself, save the file and open with IDLE. See Running programs in IDLE for more details on how to do this)
Using keyboard input
User input is information given to a program by the user. Every program has some sort of user interaction, from getting a character’s name for a game to asking for a password to log into an account.
We’ll be focusing on user inputs from the keyboard, but that’s not the only kind there is (also: swiping on a touchscreen, mouse click, voice, etc).
1. Search for “IDLE” in the Start Menu & click to open it.
IDLE is a development environment for Python. It has two main window types, the Shell window and the Editor window. For this example, we will be using the Editor window.
2. To open the Editor window, click: [File → New File]
3. In the new window, type the following code:
name = input("What is your name? ")print("Hi, " + name.capitalize())