Page 117 - Trackpad_V5_Book 6
P. 117

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 does not allow you to save our commands written on the command prompt, it gives
            output immediately after pressing the Enter key. If you want to see all the output after completion
            of the code, then you can use the Python script mode. It also allows you to type multi-line codes
            that we save for further use.

            To open Python Editor’s Window: click on the File menu    click on the New File option.









            The output is displayed in the next line in the same 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 executes. (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>)

            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.



                                                                                        Introduction to Python  115
   112   113   114   115   116   117   118   119   120   121   122