Python 4.4 - Points to remember
Points to remember
·
Operators are symbols used to perform some
operations on operands. For example, in statement z=x+y, ‘+’ and ‘=’ are
operators and ‘x’, ‘y’ and ‘z’ are operands. Addition operator is used here to
add two operands ‘x’ and ‘y’ and assignment ‘=’ operator is used to assign the
result of addition to operand ‘z’.
·
Operators which operate upon single operand are
called Unary operators such as unary ‘+’ and unary ‘-’. For example, -5, -6.8
·
Operators which operate upon two operands are
called Binary operators such as addition, subtraction etc. For example, 5+7,
45-23, x+y, x/y
·
Arithmetic operators perform mathematical
calculations such as addition, subtraction, multiplication, division. Modulus,
floor division and exponentiation.
·
Assignment operator ‘=’ is used to assign a
value to the left side variable.
·
There are compound assignment operators such as
‘+=’, ‘-=’, ‘*=’, ‘/=’, ‘//=’, ‘%=’ and ‘**=’ which are used to represent short
hand notations of actual statements.
·
Relational operators are used to compare two
values. The result of a relational statement is always either True or False.
·
Logical operators are used to combine multiple
conditions together.
·
‘5<7’, ‘8==5’, ‘3!=5’, ‘6>=3’ are
relational statements since they contain relational operators. And the result
of a relation statement is always either True or False.
·
‘5<7
and 8>2’, ‘8==5 or 7<43’
are logical statements since they contain logical operators. And the result of
a logical statement is always either True or False.
·
‘x=x+5’, ‘x=x-8’, ‘x=x/12’ can be written as ‘x+=5’,
‘x-=8’, ‘x/=12’ which are short hand notations of those statements.
·
Bitwise operators work on each bit of a number
i.e. they work on binary numbers.
·
Identity operators compare memory locations of
two objects not the values.
·
Membership operators are used to check whether
an element is present in a sequence or not.
·
Which operator will be executed first in an
expression when there are many operators is called operator precedence.
·
When multiple operators with same precedence are
used in a single expression then where to start execution i.e. from Left to
Right or from Right to Left, is known as operator associativity.
·
A module is a file that contains Python code
such as our Python programs and pre-defined Python libraries.
·
We can import a module in a program in many ways
using ‘import’ keyword such as –
1.
import modulename
2.
import modulename as nickname
3.
from modulename import object1, object2, …..
4.
from modulename import *
Thanks for knowledge
ReplyDelete