回答編集履歴
4
    
        answer	
    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
    
        answer	
    CHANGED
    
    | 
         @@ -20,7 +20,7 @@ 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            op_char = input('enter a OPERAND (+,-,*./):')
         
     | 
| 
       22 
22 
     | 
    
         
             
            op_func = ops[op_char]
         
     | 
| 
       23 
     | 
    
         
            -
            A 
     | 
| 
      
 23 
     | 
    
         
            +
            A       = input('enter a "A"              :')
         
     | 
| 
       24 
24 
     | 
    
         
             
            B       = input('enter a "B"             :')
         
     | 
| 
       25 
     | 
    
         
            -
            result 
     | 
| 
      
 25 
     | 
    
         
            +
            result  = op_func(int(A),int(B))
         
     | 
| 
       26 
26 
     | 
    
         
             
            ```
         
     | 
2
    
        answer	
    CHANGED
    
    | 
         @@ -1,6 +1,10 @@ 
     | 
|
| 
       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は困ります。
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
            ポイントは、上記リンクのコードが今のPythonではtype error(stringをoperatorでさばけない)が起きるので、入力した数値をintegerにするです。
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       4 
8 
     | 
    
         
             
            全てコピペするとinput関数がうまくいきませんので、一行ずつ走らせてください。
         
     | 
| 
       5 
9 
     | 
    
         
             
            ```Python3
         
     | 
| 
       6 
10 
     | 
    
         
             
            import operator
         
     | 
1
-1 voteが理解できない
    
        answer	
    CHANGED
    
    | 
         @@ -1,1 +1,22 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            [assign operator to variable in python?](https://stackoverflow.com/questions/2983139/assign-operator-to-variable-in-python)
         
     | 
| 
      
 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 
     | 
    
         
            +
            ```
         
     |