Page 154 - Computer Science V2.0 Class 11
P. 154

Finally, let us consider the following print statements and the outputs produced on their execution:

                                                       Statements with output

                    >>> print('Python')                  # Print a string
                        Python
                    >>> print('Python', 'Language')    # Two strings are separated by a space
                        Python Language
                    >>> print(3*50+42)           #Arithmetic expression is evaluated and then printed
                        192
                    >>> num = 7
                    >>> print('Your lucky number is  ', num) #A string constant and a variable

                        Your lucky number is   7
                    >>> print()                           #A blank line is printed
                    >>>
                    >>> print('Python', 'Language' , sep='**')#The two strings separated by '**'

                        Python**Language
                    >>> print('Python', 'Language', end='@@@') # Output ends with '@@@'

                        Python Language@@@
                    >>> print('Python', 'Language', sep='**', end='@@@')
                                                    #Use of both sep and end clause
                        Python**Language@@@



                     A print() can continue in the next line by using a backlash (\). For example:
                     >>> print("Come and \           Backslash at the end does not
                     complete your work", end='###')  allow the print() to terminate
                     output:
                     Come and complete your work###





                      Give one word answer to what each of the following is called:
                      1.  Which statement is included but not executed in the program?
                      2.  In a Python program, which function is used to accept input from a user?
                      3.  What will be the output produced on the execution of the following statement?

                          >>> print('Two','plus','two', sep='#',end='is four')


              Common Errors

              ● Using keywords as variable names

               if = 10    --------> if is a keyword
              ● Missing quotation marks for strings
               print(India) --------> string value not enclosed in quotation marks




               140   Touchpad Computer Science (Ver. 2.0)-XI
   149   150   151   152   153   154   155   156   157   158   159