-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogical_expressions.md2
More file actions
170 lines (137 loc) · 1.97 KB
/
logical_expressions.md2
File metadata and controls
170 lines (137 loc) · 1.97 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
## Test case: and expression
JavaScript:
```js
var1 == var2 && i == 10;
```
Python:
```py
var1 == var2 and i == 10
```
## Test case: or expression
JavaScript:
```js
var1 == var2 || i == 10;
```
Python:
```py
var1 == var2 or i == 10
```
## Test case: negation
```js
!temp;
```
Python:
```py
not temp
```
## Test case: and then or expression
JavaScript:
```js
false && true || true
```
Python:
```py
False and True or True
```
## Test case: or then and expression
JavaScript:
```js
false || true && true
```
Python:
```py
False or (True and True)
```
## Test case: and then parentheses with or expression
JavaScript:
```js
false && (true || true)
```
Python:
```py
False and (True or True)
```
## Test case: another one
JavaScript:
```js
false && true && true
```
Python:
```py
False and True and True
```
## Test case: another one with parentheses
JavaScript:
```js
(false && true) && true
```
Python:
```py
(False and True) and True
```
## Test case: another two
JavaScript:
```js
false || true && false
```
Python:
```py
False or (True and False)
```
## Test case: chained logical expressions
JavaScript:
```js
false || true && false || true && false || true
```
Python:
```py
False or (True and False) or (True and False) or True
```
## Test case: chained logical expressions 2
JavaScript:
```js
var1 == var2 && var3 != var4 || var5 === var6
```
Python:
```py
var1 == var2 and var3 != var4 or var5 == var6
```
## Test case: logical not expression
JavaScript:
```js
!false && true || !true
```
Python:
```py
not False and True or not True
```
## Test case: mixed operators
JavaScript:
```js
false && true || false && true || true
```
Python:
```py
False and True or False and True or True
```
## Test case: mixed operators2
JavaScript:
```js
if(false || !true && false || false) {
var z = 1
}
```
Python:
```py
if False or not True and False or False:
z = 1
```
## Test case: mixed operators3
JavaScript:
```js
var1 && (var2 && var3)
```
Python:
```py
var1 and (var2 and var3)
```