Page 132 - Computer Science Class 11 Without Functions
P. 132
6.3.4 L-value and R-value
Consider the following assignment statement:
sum = x+20
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
6.4 Functions
Python provides a lot of functionality to its users in the form of built-in functions. We have already used one such
function, namely, the print() function. A function performs its task based on a list of arguments. To invoke a
function, we write the name of the function, followed by its list of arguments, enclosed within a pair of parenthesis. A
pair of adjacent parameters are separated from each other by a comma. In the Python code, a blank is usually inserted
after a comma to make the code easily readable. A function may be invoked wherever necessary in the Python code.
For example,
>>> country = "India"
>>> print('My country is', country)
My country is India
Note that when we invoke the function print() with the arguments 'My country is' and country, Python
displays the message My country is, followed by the value of the variable country, i.e., India. To make the output
produced by the function print() easily readable, Python inserts a blank to separate different values. Next, let us
examine another example of the use of the function print(). In the following Python code, the print() function
has been invoked with five arguments, namely, 'My country is', country, 'Area of my country is',
area, and 'Sq Km':
>>> area = 3287000
>>> print('My country is', country, 'Area of my country is', area, 'Sq Km')
My country is India Area of my country is 3287000 Sq Km
A function performs a specific task. To invoke a function, the name of the function is followed by a list of arguments,
enclosed within a pair of parentheses.
6.5 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 in the software development team as well as the users of the software.
Indeed, developing large and complex software requires programmers to work in a team.
130 Touchpad Computer Science-XI

