【发布时间】:2012-11-22 09:07:31
【问题描述】:
我刚刚在python中编写了一个简单的计算器脚本,通常python默认应该识别(-)减号,(*)乘法,(/)除号,但是在考虑这个脚本时它无法识别符号。请留下你的cmets来清理我......
#! /usr/bin/python
print("1: ADDITION")
print("2: SUBTRACTION")
print("3: MULTIPLICATION")
print("4: DIVISION")
CHOICE = raw_input("Enter the Numbers:")
if CHOICE == "1":
a = raw_input("Enter the value of a:")
b = raw_input("Enter the value of b:")
c = a + b
print c
elif CHOICE == "2":
a = raw_input("Enter the value of a:")
b = raw_input("Enter the value of b:")
c = a - b
print c
elif CHOICE == "3":
a = raw_input("Enter the value of a:")
b = raw_input("Enter the value of b:")
c = a * b
print c
elif CHOICE == "4":
a = raw_input("Enter the value of a:")
b = raw_input("Enter the value of b:")
c = a / b
print c
else:
print "Invalid Number"
print "\n"
【问题讨论】:
-
我不明白这个问题。您不处理此脚本中的标志,您处理数字。 (虽然 a 和 b 的类型有一个单独的问题。)
-
对了,我是
division。
标签: python calculator