- numbers: int, float, complex
- boolean: bool
- none!: NoneType, one constant has been defined for the only value it does take
None
description | name of method | usage | example |
---|---|---|---|
negation | (__neg__ ) |
-self |
-a , -1 |
description | name of method | usage | example |
---|---|---|---|
not | (__not__ ) |
not self |
not True |
description | name of method | usage | example |
---|---|---|---|
add | (__add__ ) |
self + other |
1 + 21 , "hello" + "world" |
sub | (__sub__ ) |
self - other |
1 - 21 , {1, 2, 3, 4} - {1, 2} |
div | (__div__ ) |
self / other |
1 / 21 , 102.1 / 2 |
mul | (__mul__ ) |
self * other |
1 * 21 , "ATCGC" * 10 |
mod | (__mod__ ) |
self % other |
100 % 2 , "Hello %s" % ("Jack") |
floordiv | (__floordiv__ ) |
self // other |
1 // 21 |
pow | (__pow__ ) |
self ** other |
2 ** 10 |
description | name of method | usage | example |
---|---|---|---|
eq | (__eq__ ) |
self == other |
1 == 21 , (1, 2) == (1, 2) |
ne | (__ne__ ) |
self != other |
1 != 21 |
gt | (__gt__ ) |
self > other |
1 > 21 |
ge | (__ge__ ) |
self >= other |
1 >= 21 |
lt | (__lt__ ) |
self < other |
100 < 2 |
le | (__le__ ) |
self <= other |
1 <= 21 |
description | name of method | usage | example |
---|---|---|---|
and | (__and__ ) |
self and other |
True and True |
or | (__or__ ) |
self or other |
True or False |
is | self is other |
a is b |
|
is not | self is not other |
a is not b |
|
in | (__in__ ) |
self in other |
1 in [1, 2, 3, 4] |
print()
:type()
:
int()
,float()
,complex()
,str()
,bool()
,NoneType()
list()
,tuple()
,dict()
,set()
range()