Programming – What is Input?

One form of input…

Yesterday, we looked at What is a Variable and one of the things we discovered variables are used for is storing user input. Most of the interesting programs in the world will include some form of user input. Whether it be personalising your experience by asking your name, accepting a user name and password to log you into your account or by allowing you to input some numbers to perform calculations on. These are all examples of user input.

So, What Is Input?

Input is any data that is received into the computer program. We often think of direct input such as using our mouse or keyboard. But input can come from other devices connected to our computers. For example, a temperature sensor plugged into a computer can be providing input about the current temperature it is sensing in its surroundings.

Programs often require data to be input to perform a task on it. Such data is then utilised by programs (or processed) and often this is used in calculations or processes to produce new data (or information – which is data in context) and outputs this to a user. We’ll delve into output more deeply in another article, but this could take the form of displaying a message or result on a screen or saving data to a file.

Forms of Input

Forms of input can include:

  1. Mouse clicks to select an option or drag an item to an appropriate place on a scale.
  2. Text entered into a computer (such as this blog post!). This can also include typing a letter into a word processor.
  3. Sensors – as discussed above – can provide readings to a computer program.
  4. Files – uploading a file of orders to be processed.

‘Hello World’ example

A traditional ‘Hello World’ program in Python may look like this:

print("Hello World")

This would generate user output as:

Hello World

That’s great for starters, but how can we enhance it to make it a little more interesting? We could use input (and a variable).

name = input("What is your name?")
print("Hello World.  Welcome to my program,", name

This would produce the following output (user entered input highlighted in bold):

What is your name?  David
Hello World.  Welcome to my program, David

First the program asks my name, I enter input, using the keyboard, “David”. Then the program announces Hello World and welcomes me by name to the program.

Quite a simple program, but in just an extra line we’ve personalised the experience! Of course, here we’ve just taken the input and spat it back out to the user with some additional text but input can be used for a variety of complex and less-complex methods to make an immersive experience for the user.

We’ll dive into input in more detail in future articles, but hopefully this has provided you with a nice little introduction to the possibilities of user input. Any questions or any extra topics you’d like to see covered? Throw them in the comments below!

You may also like...

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x