In this step-by-step Python tutorial, you’ll learn how to take user input from the keyboard with the built-in function input(), how to display output to the console with the built-in function print(), and how to format string data with the string modulo operator.

To be useful, a program usually needs to communicate with the outside world by obtaining input data from the user and displaying result data back to the user. This tutorial will introduce you to Python input and output.

Input may come directly from the user via the keyboard, or from some external source like a file or database. Output can be displayed directly to the console or IDE, to the screen via a Graphical User Interface (GUI), or again to an external source.

In the previous tutorial in this introductory series, you:

  • Saw a comparison of some different paradigms used by programming languages to implement definite iteration
  • Learned about iterables and iterators, two concepts that form the basis of definite iteration in Python
  • Tied it all together to learn about Python’s for loops

By the end of this tutorial, you’ll know how to:

  • Take user input from the keyboard with the built-in function **input()**
  • Display output to the console with the built-in function **print()**
  • Format string data with the string modulo operator

Without further ado, let’s dive in!

#python

Basic Input, Output, and String Formatting in Python
3.85 GEEK