-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path008_logical_special.py
97 lines (97 loc) · 2 KB
/
008_logical_special.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> # logical Operators
>>> # logical AND , Logical OR , Logical NOT
>>> # Logical AND ----->>> and is a keyword which is used for to do the logical AND operation
>>> # input1 and inpput2 ----->>>> input1/ input2
>>> # input1 and input2 ------>>> True/ False
>>> True and True
True
>>> True and False
False
>>> False and True
False
>>> False and False
False
>>> # input1 --->> result when the input1 is False
>>> # input2 --->> result when the input1 is True
>>> 67 and 78
78
>>> # int --->>> 0--> False , +ve/-ve ----> True
>>> # float --->> 0.0-> False , +ve/-ve ----> True
>>> # complex --> 0 + 0j --> False , ow--->>>> True
>>> # None ------>> False
>>> # str, list, tuple, set, dict ----->> len of any thing--> 0 ---> False
>>> [] and 45
[]
>>> {34,90} and (34,89)
(34, 89)
>>> "" and {}
''
>>> " " and {}
{}
>>> # Logical OR ----->>> or is a keyword which is used for to do the logical OR operation
>>> # input1 or inpput2 ----->>>> input1/ input2
>>> # input1 --->> result when the input1 is True
>>> # input2 --->> result when the input1 is False
>>> [] or 90
90
>>> {4,3} or 0
set([3, 4])
>>> "" or {}
{}
>>> " " or {}
' '
>>> # logical NOT ----->>> not
>>> not {1,2,3}
False
>>> not ""
True
>>> # in
>>> 78 in {45,90,23,78}
True
>>> 90 in {45,78,34}
False
>>> # not in
>>> 78 not in {56,90,78}
False
>>> 90 not in {45,89,23}
True
>>> # is
>>> a = 123
>>> b = 123
>>> id(a)
37515280L
>>> id(b)
37515280L
>>> a is b
True
>>> c = 124
>>> id(c)
37515256L
>>> a is c
False
>>> a = [1,2,3,4]
>>> b = [1,2,3,4]
>>> c = a
>>> a
[1, 2, 3, 4]
>>> b
[1, 2, 3, 4]
>>> c
[1, 2, 3, 4]
>>> id(a)
37171848L
>>> id(b)
50154376L
>>> id(c)
37171848L
>>> a is b
False
>>> a is c
True
>>> a is not b
True
>>> a is not c
False
>>>