Oct-17-2019, 04:13 PM
I've just started GCSE computer science about a month ago, I already knew the basics of python like variables, if and else statements and stuff, and this is the first big task we've done. We're making a calculator and for some reason, when you ask it to subtract, it adds the numbers together. I have no clue why, I even showed it to my teacher who had no clue why it was adding instead of subtracting. I took it home to try and work on and I'm still not understanding the problem. I'm not sure what version of python we use in school but I'm on 3.8.0 on my laptop. Both my laptop and my school's run windows 7. Can anyone help me?
import time print ("Hi! I'm Carrie the Calculator. :)") time.sleep(1) print ("What would you like to do?") time.sleep(1) command = input("Add or Subtract?") if command == "ADD" or "add" or "plus" or "addition" or "Addition" or "Add" or "A" or "a": print ("Oh, addition! This will be fun") time.sleep(1) input1 = input("What is the 1st number?") input2 = input("What is the 2nd number?") number1 = int(input1) number2 = int(input2) result = number1 + number2 output = str(result) time.sleep(0.3) print(input1 + " + " + input2 + " = " + output) elif command == "Subtract" or "SUBTRACT" or "Take away" or "take away" or "subtract" or "sub" or "s" or "S": print ("Subtraction! I'm great at that!") time.sleep(1) input1 = input("What is the 1st number?") input2 = input("What is the 2nd number?") number1 = int(input1) number2 = int(input2) result = number1 - number2 output = str(result) time.sleep(0.3) print(input1 + " - " + input2 + " = " + result) else: print ("Sorry, that isn't something I can do. :(")