Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 138 - logicode 2609 C6
P. 138

    Short key  To close IDLE window:             Subject: To exit IDLE window

                                                                                To exit  the  IDLE window, click  on
                                                 +
                                         Ctrl
                                                     D
                                                                                File menu
                                                                                            Exit option.

                      SCRIPT MODE (EDITOR’S WINDOW)
                      Python Shell executes commands immediately and doesn't save them for later use. For multi-
                      line code and to save your work for future use, you should use Python script mode. This allows
                      you to write larger programs and run the same code multiple times. Save your code in a file, for
                      example, 'filename.py', and run it to see all the output after execution. To open Python Editor’s
                      Window: click on the File menu    click on the New File option.

                      The output is displayed in the Python Shell window.

                                INPUT AND OUTPUT

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

                      THE input() FUNCTION
                      We use the input() function to take the user’s input while a program is being executed. (This
                      function also evaluates the expression whether the user has entered a string, number or list right
                      after receiving input.) The general syntax of the input() function is as follows:

                      Variable_name = input(<message to be displayed>)
                      Example:
                      >>> name = input("Enter your name: ")
                           Enter your name: Trackpad

                      By default, Python considers the input as string even if you entered a number as input. You cannot
                      perform calculations on string. To perform calculations, you need to convert the string into integer
                      or floating-point value.

                      136   Premium Edition-VI

| 133 134 135 136 137 138 139 140 141 142 143 |