回答編集履歴

3

紛らわしいところを書き換えた

2023/04/21 15:20

投稿

quickquip
quickquip

スコア11040

test CHANGED
@@ -29,7 +29,7 @@
29
29
  `"a" in menu or "b" in menu or "c" in menu and "d" not in menu` の評価順は
30
30
  1. `"a" in menu` を評価して True
31
31
  1. `True or "b" in menu` は左側がTrueなので `"b" in menu` を**評価しないで** True
32
- 1. `True or ("c" in menu and "d" not in menu)` は左側がTrueなので括弧の中を**評価しないで** True
32
+ 1. `True or "c" in menu and "d" not in menu` はorの左側がTrueなので`"c" in menu and "d" not in menu`を**評価しないで** True
33
33
  です。
34
34
 
35
35
  `("a" in menu or "b" in menu or "c" in menu) and "d" not in menu` の評価順は、

2

誤記修正

2023/04/21 11:59

投稿

quickquip
quickquip

スコア11040

test CHANGED
@@ -37,7 +37,7 @@
37
37
  1. `True or "b" in menu` は左側がTrueなので `"b" in menu` を**評価しないで** True
38
38
  1. `True or "c" in menu` は左側がTrueなので `"c" in menu` を**評価しないで** True
39
39
  1. `"d" not in menu`を評価して False
40
- 1. `True or False` を評価してFalse
40
+ 1. `True and False` を評価してFalse
41
41
  です。
42
42
 
43
43
  https://docs.python.org/ja/3/reference/expressions.html#boolean-operations

1

1文追加

2023/04/21 11:54

投稿

quickquip
quickquip

スコア11040

test CHANGED
@@ -24,7 +24,7 @@
24
24
  補遺
25
25
 
26
26
  結合の優先度 と 評価の順番 を混ぜて考えては駄目です。
27
-
27
+ 括弧は、結合の優先度を変えるのであって、**評価の順番を変えたりはしません**。
28
28
 
29
29
  `"a" in menu or "b" in menu or "c" in menu and "d" not in menu` の評価順は
30
30
  1. `"a" in menu` を評価して True