Page 13 - Modular v1.1 Pyhton
P. 13

The program will execute and the output will be shown in the Shell window.
















                                                                Output

                     INPUT AND OUTPUT IN PYTHON

                 Python provides two commonly used functions input( ) and print( ) for input and output.

                 The input( ) Function

                 The input( ) function takes the user’s input while a program executes. The general syntax of the

                 input( ) function is as follows:

                 input([<prompt>])
                 Here, prompt is the string or message we wish to display on the screen. Example:
                    name = input("Enter your name: ")

                    >>> Enter your name: "Mohan"

                 The print( ) Function


                 The print( ) function prints or sends the output to the standard output device, which is usually a
                 monitor. This function auto converts the items to strings, i.e., if you try printing a numeric value,
                 the print( ) function will automatically convert it into equivalent string and print it. The print( )
                 function also introduces spaces between items automatically.
                  Clickipedia




                   Unlike Java  and C++, Python  does not use brackets to delimit  code;  but indentation  is
                   mandatory with Python.


                 The general syntax of the print( ) function is as follows:

                 print [<expression 1> , <expression 2>...]

                 For example:

                 print ("Python is easy")






                                                                                         Introduction to Python   11
   8   9   10   11   12   13   14   15   16   17   18