4 回答
TA贡献2036条经验 获得超8个赞
这是您的正确代码
print("Calculator for substraction, addition, multiplication and division")
sign=input("Enter a sign:")
num1=float(input("Enter a number:"))
num2=float(input("Enter a second number:"))
def wrong_sign():
print("Sign entered is invalid please use one of those 1. - for substraction \n 2. + for addition \n 3. x or * for multiplication \n 4. / for devision")
if sign == "-":
print(num1-num2)
elif sign == "+" :
print(num1+num2)
elif sign == "/":
print(num1/num2)
elif sign == "*" or sign == "x":
print(num1 * num2)
else:
wrong_sign()
无效符号的输出
Calculator for substraction, addition, multiplication and division
Enter a sign:$
Enter a number:2
Enter a second number:3
Sign entered is invalid please use one of those 1. - for substraction
2. + for addition
3. x or * for multiplication
4. / for devision
添加回答
举报