-2

これは特定のプログラム用ではない数行のコードを練習しているだけですが、私を悩ませているのは、印刷の横に入力カーソルを表示したいのですが、同時に変数を定義する必要があることですあなたeeできないのと同じ行です4。これが私のコードです:

a = int(input("Give me a Number: "))
b = int(input("Give me another number: "))
c = b + a
def none():
    pass
e = none()
print("the sum of"), a, ("and"), b, ("is"), c

d = int(input("Please Insert your age here: "))
if d < 18:
    print("Sorry you must be 18 years or older to enter this site")
else:
    print("Welcome to www.example.com")
print("What is 2+2: "), e == int(input("")),
if e == 4:
    print("good Job!")
else:
    print("sorry no")
4

2 に答える 2

3

次のような意味ですか。

print("What is 2+2: "); e=int(input(""))

tuple現在のコードは、実際にはprint( None) の結果と式の結果のを作成しようとしています。これは、まだ定義されていないため、 が得られなかったe==int(input(""))場合、通常はブール値になります。eNameError


通常、これらの状況では、おそらく次のようにすることに注意してください。

e = int(input("What is 2+2: "))
于 2013-03-28T06:03:29.333 に答える
1

(が式に等しいことe == int(input(""))を意味する) と(式の値を に代入することを意味する) には違いがあることに注意してください。ee = int(input(""))e

に値を割り当てる必要がありますe

于 2013-03-28T06:05:45.720 に答える