Page 61 - Information_Practice_Fliipbook_Class11
P. 61
Examples of Invalid Identifiers (variable names)
My name (Space included)
1day (Starts with a digit)
Come#go (Contains a special character, #)
max-marks (Contains a special character, - (hyphen))
Which of the following identifiers are valid/invalid?
#metoo, _dayName, print, add&subtract, first name, currenyIn$
In Python, the type of a variable is not declared explicitly. Instead, a variable gets associated with a type that is
determined implicitly from the context. For example, consider the following statements appearing in a program, one
after the other:
x = 23 #s1
x = 23.25 #s2
x = 'hello' #s3
In statements s1, s2, and s3, the variable x denotes an integer (23), a floating point number (23.25), and a string
('hello'), respectively. Thus, unlike C++ like languages, a variable does not have a type associated with it. Instead,
it implicitly gets associated with the type object it refers to.
3.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.
Basics of Python Programming 47

