PYthon Class 8 Telugu
PYthon Class 8 Telugu
====================
Operator
~~~~~~~~~~~~~
Operand
~~~~~~~~~~~
eg:
a+b
Arithmetic Operators
~~~~~~~~~~~~~~~~~~~~~~~~~
>>> a=10
>>> b=20
>>> c=a+b
>>> c
30
>>>
>>> c=a-b
>>> print(c)
-10
>>>
>>> c=a*b
>>> print(c)
200
>>>
>>> c=b/a
>>> print(c)
2.0
>>>
>>>
>>>
>>> a=25
>>> b=3
>>>
>>> c=a/b
>>> print(c)
8.333333333333334
>>>
>>>
>>> c=a%b
>>> print(c)
1
>>>
>>>
>>>
>>> c=a//b
>>> print(c)
8
>>>
>>>
>>>
>>> a=2
>>> b=3
>>>
>>> c=a**b
>>> print(c)
8
>>>
eg:
a=int(input("Enter A Value:"))
b=int(input("Enter B Value:"))
c=(a+b)**3
print("(a+b)^3 =",c)
eg:
Chaining Operators
----------------------
>>> a=b=c=d=e=10
>>> print(a)
10
>>> print(b)
10
>>> print(c)
10
>>> print(d)
10
>>> print(e)
10
>>>
>>>
>>> a,b,c,d=10,20,30,40
Note:
~~~~~~~~~
If we use * for str type then compulsory one argument must be int and another
argument must be of int type
eg:
Note:
~~~~~~~~~~~
>>> a='edusaa'
>>> b='edusaa'
>>>
>>> print(a>b)
False
>>>
>>>
>>> print(a<b)
False
>>> print(a>=b)
True
>>> print(a<=b)
True
>>>
>>>
>>> print(a==b)
True
The relational operators are also applicable to boolean types i.e, True or
False
eg:
>>> print(True+True)
2
>>>
>>>
>>>
>>> print(True>False)
True
>>>
>>>
>>> print(True<False)
False
>>>
>>>
>>> print(True>=False)
True
>>>
>>>
>>> print(True<=False)
False
>>>
>>>
>>> print(10>True)
True
>>>
>>>
>>>
>>> print(True<10)
True
>>>
>>>
>>> print(10.5>5.5)
True
>>>
>>>
>>> print(10.5>True)
True
>>>
>>> print(10.5>True>False)
True
>>>
>>>
>>>
>>>
Logical Operators
----------------------
x and y
~~~~~~~~~~~~
eg:
>>> 10 and 100
100
>>>
>>>
>>> 0 and 10
0
>>>
>>>
x or y
~~~~~~~~~~~~~~
eg:
>>> 10 or 100
10
>>>
>>>
>>> 100 or 10
100
>>>
>>> 0 or 10
10
>>>
>>>
>>> 10 or 0
10
>>>
>>>
>>> 0 or 100
100
>>>
Not x
==========
eg:
Bitwise Operators
====================
eg:
>>> print(100&200)
64
>>>
>>> print(100.5&200.5)
Traceback (most recent call last):
File "<pyshell#222>", line 1, in <module>
print(100.5&200.5)
TypeError: unsupported operand type(s) for &: 'float' and 'float'
>>>
>>>
>>> print(True&False)
False
>>>
>>>
1--> 0
0 --> 1