-1
pythonプログラムでプログラムを書くと、合計を見つけることができます。それを押すと合計が見つかり、pを押すとproductを見つけます。他の文字を入力すると、間違って入力されます。 character.ch値Sと比較されていないか、またはp.error Sは3つの数の積と和を求める
a = input("enter a number\n")
b = input("enter a number\n")
c = input("enter a number\n")
print "enter s for sum and p for product"
ch = input("enter character")
if(ch=='s'):
s = a+b+c
print "the product of the number:" +s
elif(ch =='p'):
p = a*b*c
print "the product of the number:" +p
else:
print "entered invalid character"
入力から読み出し文字列を使用raw_input
Name error: name 's' is not defined
#dharmesh sir its working.please私にpythonの良い本を教えてください。私はpythonの初心者です。私はc、C++、php、javaでやったことがあります。 –
@ManjotSinghここから基本概念を学ぶことができます。初心者のために非常に役立ちます: https://www.cs.uky.edu/~keen/115/Haltermanpythonbook.pdf – Dharmesh