Class 14 Operator 2
Class 14 Operator 2
symbol are:-
& :- and
| :-or
^ :-Xor
~ :-Not
<< :- bitwise rightindia nai tiobk batuibkeej ubd indian
arngudfoaoddofhsdsoihfodhfvx jjsddgf
10--->int
'scodeen'--->str
10.5--->float ex:-
x = eval(input('First number:'))
y = eval(input('second number'))
print(x+y)
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
Output:-
10--->int
'scodeen'--->str
10.5--->float
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
Note:- But in python3 we have only input() method and eaw_input() method is not
available.
python 3 input() function behaviour exactly same as raw_input() method of py2 that
is every input value is treated as str type only.
1.Arithmetic Operators
2.Relational or comparision operatos
3.Logical Operatos
4.Bitwise Operators
5.Assignment Operatos
6.Special Operator.
1.Arithmetic Operators:-
+ :- addition
- :- subtraction
* :-multiplication
/ :-Division
% :- modulo operator
// :- floor division
** :-Exponent operator or power operatos
Assingment Operators:-
ex:- x = 10
we can combine assingment operator with some other operator to form compound
assignment operator.
x = x+10
x+=10 == x= x+10
x-=10 == x= x-10
x*=10 == x= x*10
x/=10 == x = x/10
special operators:-
1.Identity Operator.
2.Membershiop Operator.
1.Identity Operator:-
we can use identity operators for address comparision.
is :- 1st object and 2nd object returns True if both 1st and 2nd pointing to the
same objevt.
is not:- 1st object and 2nd object returns True if both 1st and 2nd not pointing
to the same object.
>>> a = 10
>>> b = 10
>>> a is b
True
>>> a is not b
False
>>> id(10)
2374830221904
>>> id(a)
2374830221904
Note:- we can use is operator for address comparision where as == opearator content
comparision.
2.Membership operator.(imp):-
We canm use memebership opeartors to check whether the given object present in
given collection(It may be string,list,set,tuple and dict.)
in-> Returns True if the given object present in the specified collection.
not in -> Returns True if the given object not present in specified collection.
>>> a = [10,20,30,40]
>>> 10 in a
True
>>> 50 in a
False
>>>
>>> 70 not in a
True
>>>
>>> 30 not in a
False
>>>
ex:- print(3+10*2)
():- parenthesis
**:- Exponential opearator
~,- :- bitwise complement
*,/,%,//:- mul,div,modulo,floor
+,- :- addtion,substration
<<,>> :- left and right shift
&:- bitwise and
^:- Bitwise X-or
| :- Bitwise OR
>,<,>=,<=,==,!=:-relation operator
=,+=,-=,*=,/=:- Assignment operators
is,is not:- identity opeartor
in,not in:- Membership operators
not:- logical not
and :- logical and
or: logocal or