回答編集履歴

4

 

2022/06/27 22:48

投稿

退会済みユーザー
test CHANGED
@@ -3,7 +3,7 @@
3
3
  -1 voteが理解できないので答えを張り付けます。
4
4
  **正義の(?)鉞を投げつけられるのは構いません**が、根拠のない-1 voteは困ります。
5
5
 
6
- ポイントは、上記リンクのコードが今のPythonではtype error(stringをoperatorでさばけない)が起きるので、入力した数値をintegerにするです。
6
+ ポイントは、上記リンクのコードが今のPythonではtype error(stringをoperatorでさばけない)が起きるので、入力した数値をintegerにする、割り算の書き方が少し変わったよう今に合うように書き換える、です。
7
7
 
8
8
  全てコピペするとinput関数がうまくいきませんので、一行ずつ走らせてください。
9
9
  ```Python3

3

2022/06/27 22:35

投稿

退会済みユーザー
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  op_char = input('enter a OPERAND (+,-,*./):')
22
22
  op_func = ops[op_char]
23
- A = input('enter a "A" :')
23
+ A = input('enter a "A" :')
24
24
  B = input('enter a "B" :')
25
- result = op_func(int(A),int(B))
25
+ result = op_func(int(A),int(B))
26
26
  ```

2

 

2022/06/27 22:33

投稿

退会済みユーザー
test CHANGED
@@ -1,5 +1,9 @@
1
1
  [assign operator to variable in python?](https://stackoverflow.com/questions/2983139/assign-operator-to-variable-in-python)
2
2
 
3
+ -1 voteが理解できないので答えを張り付けます。
4
+ **正義の(?)鉞を投げつけられるのは構いません**が、根拠のない-1 voteは困ります。
5
+
6
+ ポイントは、上記リンクのコードが今のPythonではtype error(stringをoperatorでさばけない)が起きるので、入力した数値をintegerにするです。
3
7
 
4
8
  全てコピペするとinput関数がうまくいきませんので、一行ずつ走らせてください。
5
9
  ```Python3

1

-1 voteが理解できない

2022/06/27 22:30

投稿

退会済みユーザー
test CHANGED
@@ -1 +1,22 @@
1
1
  [assign operator to variable in python?](https://stackoverflow.com/questions/2983139/assign-operator-to-variable-in-python)
2
+
3
+
4
+ 全てコピペするとinput関数がうまくいきませんので、一行ずつ走らせてください。
5
+ ```Python3
6
+ import operator
7
+ ops = {
8
+ "+": operator.add,
9
+ "-": operator.sub,
10
+ "*": operator.mul,
11
+ "/": operator.truediv
12
+ }
13
+
14
+
15
+ print('The format is "A OPERAND B"')
16
+
17
+ op_char = input('enter a OPERAND (+,-,*./):')
18
+ op_func = ops[op_char]
19
+ A = input('enter a "A" :')
20
+ B = input('enter a "B" :')
21
+ result = op_func(int(A),int(B))
22
+ ```