0

Python バージョン 3.3.1 のこの初歩的な電卓プログラムでエラーが発生し続けます。自分で問題を見つけることができません。誰か助けてもらえますか? 事前にどうもありがとうございました!

    x=(input("Which operation would you like to perform?"))
        if x=='Addition':
        y=int(input("Enter the first number?"))
        z=int(input("Enter the second number?"))
        a=y+z
        print(a)
    elif x=='Subtraction':
        y=int(input("Enter the first number?"))
        z=int(input("Enter the second number?"))
        a=y-z
        print(a)
    elif x=='Multiplication':
        y=int(input("Enter the first number?"))
        z=int(input("Enter the second number?"))
        a=y*z
        print(a)
elif x=='Division':
        y=int(input("Enter the first number?"))
        z=int(input("Enter the second number?"))
        a=y/z
        print(a)
4

2 に答える 2

0

あなたのタブが台無しになっていると思います。次のようなことを試してください:

x=input("Which operation would you like to perform?")
if x=='Addition':
    y=int(input("Enter the first number?"))
    z=int(input("Enter the second number?"))
    a=y+z
    print(a)
elif x=='Subtraction':
    y=int(input("Enter the first number?"))
    z=int(input("Enter the second number?"))
    a=y-z
    print(a)
elif x=='Multiplication':
    y=int(input("Enter the first number?"))
    z=int(input("Enter the second number?"))
    a=y*z
    print(a)
elif x=='Division':
    y=int(input("Enter the first number?"))
    z=int(input("Enter the second number?"))
    a=y/z
    print(a)
于 2013-05-19T17:01:26.247 に答える
-1

x= raw_input("Which operation would you like to perform?")あなたの問題を解決します

編集: Python 3 では、raw_input の名前が input() に変更され、古い動作を取得するためにeval(input(....)) 参照http://docs.python.org/3.0/whatsnew/3.0.html#builtinsを使用します

お役に立てれば

于 2013-05-19T17:06:18.917 に答える