Page 103 - 2611_SmartGPT Pro V(5.0) C-8
P. 103

On running the above program, you will get the following output:

                     Output

                  Enter first number: 5
                  Enter second number: 4
                  The sum is 20









                        Hashtag


                      # Function: Block of organised and reusable code used to perform a single or related action.
                      # String: Sequence of characters enclosed or surrounded by single (‘ ’) or double (“ ”) quotes.






                      REVISIT


                   ▶   Functions help us to break our program into smaller parts or modules.
                   ▶   Python functions are categorised into in-built functions and user-defined functions.
                   ▶   A sequence of characters that are enclosed or surrounded by single (‘ ’), double (“ ”), or triple (“‘ ’”) quotes

                     is known as a string.

                   ▶   Two basic string operators in Python are + and *. Python uses + for concatenation and * for replication.












                 1.  Tick ( ) the correct option.


                    a.   Block  of organised and reusable  code  used to  perform a single or related  action  is called
                        _______________.

                         (i)   function                                   (ii)  string
                        (iii)   statement                                (iv)  arguments
                    b.  Identify what is not the component of Python function.

                         (i)   Arguments                                  (ii)  Return value
                        (iii)   Name of the function                      (iv)  Escape sequence







                                                                                      Functions and String in Python  101
   98   99   100   101   102   103   104   105   106   107   108