Python & Full Stack Python @ 6:00 PM (IST) by Mr.
Mahesh
Day-1 https://youtu.be/M4HiepjgZS0
Day-2 https://youtu.be/kcBYDKzi8gE
Day-3 https://youtu.be/INvYBqTzGt4
Day-4 https://youtu.be/WIEVYsfcLVo
Day-5 https://youtu.be/6uloo1wwWIk
Day-6 https://youtu.be/1JaXWo20ynQ
Day-7 https://youtu.be/jfAP_-3hkO4
Day-8 https://youtu.be/vETTU4mmBp0Python Data Types:
OPERATORS:
============
Who is an operator?
Any person who is doing certain activity is called as an operator.
What is an operator?
Operator is a symbol that performs certain operations.
1).Arithmetic operators:
+, -, *, /, %, //, **
Ex:
a = 10
b = 2
a+b #12
a-b #8
a*b #20
a/b #5.0
a%b #0
a//b #5
a**b #100
Note:
--------
-->/ operator always performs floating point arithmetic, Hence it will always
returns float value.
-->But floor division(//) can perofrm both floating point and integral arithmetid.
If args are int type then result is int type. If atleast one argument is float type
then the result is float type.
10/2 #5.0
10//2 #5
10.0/2 #5.0
10.0//2 #5.0
-->If we want to use + operator for str type then both args should be str type only
otherwise we will get an error
Ex:
'sunny' + 3 #Invalid
'sunny' + '3' #sunny3
-->If we use * operator for str type then one argument should be int and other
argument should be str type.
Ex:
'sunny' * '3' #invalid
'sunny' * 3 #valid
3 * 'sunny' #valid
'sunny' * 2.5 #invalid
Note:For any number x,
x/0 and x%0 always raise ZeroDivisionError.
2).Relational Operators:
<, <=, >, >=
Ex:
a = 10
b = 20
a < b #True
a <= b #True
a > b #False
a >= b #False
-->We can apply relational operators for str type also.
Ex:
'sunny' > 'mahesh' #True
'mahesh' > 'sunny' #False
Ex:
True > True #False
True >= True #True
10 > True #True
False > True #False
10 > 'a' #Invalid
Relational Chaining:
------------------------------
In the chaining, if all comparisions returns True then only result is True.
If atleast one comparision False then the result is False.
Ex:
10<20<30<40<50 #True
10<20<30<40<50>60 #False
3).Equality Operators:
==, !=
-->We can apply these operators for any type even for incompatible types also.
10 == 20 #False
10 != 20 #True
10 == True #False
False == False #True
'sunny' == 'sunny' #True
10 == 'sunny' #False
10 == 10.0 #True
10.1 == 10 #False
10 == '10' #False
10.10 == 10.1 #True
1 == True #True
10+3j == 10+5j #False
10+3j == 10+3j #True
Equality chaining:
10 == 20 == 30 == 40 #False
10 == 5+5 == 3+7 == 2*5 #True
4).Logical operators:
and, or, not
For boolen types behaviour:
and==>If both args are True then only result is True
or==>If one argument is True then result is True
not==>Complement
Ex:
True and False #False
True or False #True
not True #False
not False #True