Page 66 - Information_Practice_Fliipbook_Class11
P. 66

In the above statement, the variable sum on the left-hand side of the assignment operator denotes the address (&sum)
        where the value of the variable (sum) is stored. In this sense, the variable sum denotes an address, also called the
        l-value. However, this terminology is not used in the context of Python language.
        The value of the expression (x+20) on the right-hand side of the assignment operator is called the r-value. The statement

        L-value = R-value.
        is the assignment statement that assigns the value or the result of the expression on the RHS of the assignment
        operator to the L-value, that is, on its LHS. For example,
        X = 20
        Sum = X+20
        However, the following are erroneous statements as the L-value is on the RHS while the literals/expressions are on the
        RHS.

        20 = X
        X+20 = Sum

        3.9 Comments

        As mentioned earlier, comments are included in a program to make the program more readable. During the program
        execution, the comments are ignored by the Python interpreter as if they were not present. The comments constitute
        an important part of the code as these comments convey the purpose and approach of the program, thus making the
        source code easier to understand for everyone. Indeed, developing large and complex software requires programmers
        to work in a team.
        Consider the following line beginning #  that appears as the first line in Program 3.1:

        #Objective: To experiment with variables and their values
        The above line is an example of a comment. It describes the purpose of the program. As shown above, a comment in
        a line in a Python program begins with the symbol hash (#). As a comment beginning with the hash symbol extends
        up to the end of the line in which the symbol # appears, it is also known as a single-line comment.  Being a comment,
        it was ignored by the  Python interpreter during the program execution. A comment may also appear at the end of an
        executable statement. For example,
        num = 20 # assigns the value 20 to num
        However, a comment may also be a multi-line string, enclosed within triple single quotes or triple double quotes. For
        example, the first four lines in the following code snippet specify the purpose of the code:
         Program 3.4 Write a program to use the working of Multiple Line comment.

          01 '''
          02 Objective: To compute area of rectangle
          03 Output: Rectangle's area computed using length and breadth
          04 '''
          05 length, breadth = 10, 5
          06 area = length*breadth
          07 print('length of rectangle =', length)
          08 print('breadth of rectangle =', breadth)
          09 print('area of rectangle =', area)

        3.10 Input and Output

        A  computer  program  will  often  require  inputs  from  the  user,  process  them,  and  produce  an  output  for  the
        user. In Python, the  input() and  print()  functions  are  used  to  perform  the  input  and  output  operations,
        respectively.






          52   Touchpad Informatics Practices-XI
   61   62   63   64   65   66   67   68   69   70   71