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 "x":
print(num1 * num2)
else:
wrong_sign
仅当我尝试输入无效符号时,没有代码错误,因为用户什么也没有出现,并且 wrong_sign 代码不显示。
泛舟湖上清波郎朗
一只斗牛犬
湖上湖
慕桂英3389331
相关分类