0% found this document useful (0 votes)
17 views

Class 14 Operator 2

Bitwise operators can be applied to integers and booleans. The common bitwise operators are & for AND, | for OR, ^ for XOR, and ~ for NOT. Bitwise operators perform operations on the binary representations of numbers.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Class 14 Operator 2

Bitwise operators can be applied to integers and booleans. The common bitwise operators are & for AND, | for OR, ^ for XOR, and ~ for NOT. Bitwise operators perform operations on the binary representations of numbers.

Uploaded by

kunala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Bitwise Operators:-

we can apply these operators bitwise.


These operators are applicable only int and boolean datatypes.
by mistake if we are trying apply for another data type then we will get error.

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)

india nai tiobk batuibkeej ubd indian arngudfoaoddofhsdsoihfodhfvx jjsddgf

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:- raw_input function of python 2 is renamed as input() function in python3.

Output:-

we can write print() function to display outputex:-


x = eval(input('First number:'))
y = eval(input('second number'))
print(x+y)

india nai tiobk batuibkeej ubd indian arngudfoaoddofhsdsoihfodhfvx jjsddgf

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:- raw_input function of python 2 is renamed as input() function in python3.


Output:-

we can write print() function to display output

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:- raw_input function of python 2 is renamed as input() function in python3.

>> :- bitwise left.

Python proviede many operatos.

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:-

we can use assingment opeartor to assign value to the variable.

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:-

Python defines 2 special operator.

1.Identity Operator.
2.Membershiop Operator.

1.Identity Operator:-
we can use identity operators for address comparision.

2 identity opearator are available.


1.is
2.is not

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
>>>

operator precedence:- which opeartor will be evaluated first

if multiple opeartors present then which operators wll be evaluated first is


decoded by opeartor precedence.

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

You might also like