請讓我知道,如何以及在何處插入繼續在我的Python的計算器程序語句... 這是我的計劃請讓我知道,如何以及在何處插入繼續在我的Python的計算器程序語句
print "Welcome to maths calculator"
a=input("\n Enter the first number :")
b=input("\n Enter the second number :")
ch=raw_input("\nEnter the operatoions you want from following... "\
"\nAddition (+)" \
"\nSubtraction (-)" \
"\nMultiplication (*)" \
"\nDivision (/)" \
"\nPress any sign u want....: ")
if ch == '+':
print "The addition result is :", a+b
elif ch=='-':
print "The subtraction result is :", a-b
elif ch=='*':
print "The multiplication result is :",a*b
elif ch=='/':
print "The division result is :",a/b
else:
print "\nPlease choose correct one.... "
結果是
歡迎數學計算器
輸入第一個數字:12
輸入第二個數字:10
從以下內容輸入你想要的operatoions ...
加(+)減 ( - ) 乘法(*) 司(/) 按任意ü希望的跡象。 ...: - 減的結果是:2>
我在這裏需要什麼? 我想繼續工作,當一個執行完成後, 請給
'continue'是使用的語句在'for'和'while'循環中。你的程序不包含循環。所以答案是,瞭解循環並使用它們 - 一個無限的'while True'循環在這裏可以很好地工作,並帶有一個包含'break'語句的退出選項。所有這些都在官方的Python教程和其他數百個免費提供的資源中介紹。 – l4mpi