Before we begin delving into writing python programs, its important to establish the concepts of input and output and how they relate to computer programs. Every useful computer program utilizes some form of input(s) and output(s)
When a computer program is running, it sometimes (oftentimes) needs to get direction, or information from the person using the it.
For example, say we are on a desktop computer and we want to open up a web browser, navigate to google.com
, and search for mountain lions
so that we can read about them for an article we need to write.
The computer doesn’t just read our mind and know that that’s what we are trying to do (at least, not yet :).
Instead, we need to give the computer some input to let it know what we want to do and how we want it to go about it.
First we would click
on the web-browser icon to tell the computer to start it up.
It would respond by opening up a new window with the web browser.
We then would click
on the browser search bar and type
in the text “google.com” and the type
ENTER on the keyboard.
The computer would respond by connecting to the Google servers via the internet, and load up the google search page.
We then would click
the search box and type
the text “mountain lions” and type
enter again to search and view the results.
Notice that throughout this process there were two main types of inputs we gave to the computer: clicking and typing. Another common way for us to give computers input on phones and tablets (which are also computers) are touch gestures. We can do things like tap on in icon to start an app, swipe to go to a previous page, pinch to zoom, etc. Probably the three most common ways of giving a computer input are:
click
(with the mouse)type
(with the keyboardtouch
(via a touchscreen)After determining how we can give a computer input, we can also think about the types of output it can respond with.
One kind of output a computer can give is graphical
output.
For example, when we clicked on the web browser icon, the output was for the computer to display a new window on the screen.
Computers can also give audio output, for example, if you click the “play” button on a music app, it will respond by putting audio through the speakers.
Most people are used to interacting with computers that respond with graphical output, because most devices (phones, tablets, laptops, etc) have operating systems that are built around being used with mice, keyboards, or touchscreens.
However, there is an even more rudimentary type of output that computer programs can produce: plain-ole text. The programs most people use on a regular basis don’t just produce plain-text, but this is the simplest kind of output, and it what we will start by learning in these lessons. We can thus also group out output into three main categories:
graphical
(displayed on a screen)audio
(through speakers / headphones)textual
(also shown on a screen)For the first few lessons, we will stick to programs that use text (typed) inputs and text output. We won’t concern ourselves with clicks, touchscreens, fancy graphics, or playing sounds. That doesn’t mean you can’t learn how to do those things down the road, but while building your foundational programming skills, it is useful to keep the inputs and outputs simple.