Page 106 - TP_Pluse_V2.2_Class_6
P. 106

Running a Python Program

                  Follow these steps to run a Python program:
                  Step 1:   Click on Run in the Menu bar.
                  Step 2:  Click on Run Module option.












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



                                                                                                   Tech Fact

                                                                                               Interactive Mode is
                                                                                             very useful for testing a
                                                                                             code as it displays the
                                                                                               errors one by one.
                                                   Output


                          INPUT AND OUTPUT


                  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.





                  104   Plus (Ver. 2.2)-VI
   101   102   103   104   105   106   107   108   109   110   111