Python Input, Output and Import

Python language provides built-in functions like input() and print() are used for standard input and output operations respectively. Let us see the output section first.Output We use the print() function to output data to the standard output device (screen). An example use is given below.
>>> print('This sentence is output to the screen') This sentence is output to the screen >>> a = 5 >>> print('The value of a is',a) The value of a is 5

Input In Python, we have the input() function to allow this. The syntax for input() is input([prompt]) where prompt is the string we wish to display on the screen. It is optional.

>>> num = input('Enter a number: ') Enter a number: 10 >>> num '10'
Import A module is a file containing Python definitions and statements. Python modules have a filename and end with the extension .py. Definitions inside a module can be imported to another module or the interactive interpreter in Python. We use the import keyword to do this. For example, we can import the math module by typing in import math.
>>> import math >>> math.pi 3.141592653589793
Now all the definitions inside math module are available in our scope. We can also import some specific attributes and functions only, using the from keyword.

For example:

>>> from math import pi >>> pi 3.141592653589793