【发布时间】:2014-10-07 01:18:53
【问题描述】:
我正在编写这个程序,它基本上是一个有限的计算器。我正在尝试这样做,以便如果用户输入让我们说“电源”而不是所需模式的数字 1,它会打印出“无效选择”。如果他们尝试写“二次方”而不是 2 等等,其余部分也是如此。
#CALCULATOR
print("MY CALCULATOR")
print("1. Powers")
print("2. Quadratics")
print("3. Percents")
print("4. Basic Ops")
choice = int(input("Please enter your desired mode: "))
if choice == 1:
base = int(input("Enter the base: "))
exponent = int(input("Enter the exponent: "))
power = base**exponent
if choice == 2:
print("Please enter the values for A/B/C: ")
a = int(input("A: "))
b = int(input("B: "))
c = int(input("C: "))
我试过了:
if choice not == 1:
print("Invalid Selection")
和
if choice not 1:
print("Invalid Selection")
但它们似乎不起作用。如果你能告诉我我做错了什么。谢谢你。
【问题讨论】: