Can someone help me with my computer science ??? I have three things to do and I don't know how to do it. I will start posting the things I need but first I need a program using py that performs addition and subtraction of two numbers. I will help you with something you need in return
please help asap, These are easy things to do. I just don't have how to do them.
Addition and subtraction?
use a variable: number1 and number2 for example, using an input of a string to enter them, like this:
number1 = input("Input number one")
number2 = input("Now number two")
number3 = (number1) - (number2)
Exchange the - for + and you should be fine, i hope this is what you needed!
The input worked but they didn't add or subtract, it says i need to use sum(). How do I do this
Ah, instead of the number3 variable just do:
sum = (number1) + (number2)
same with the minus
Ah my bad, the inputs need to be number1 = int(input("Input number one"))
int standing for integer as its a number, not a string!
number1 = int(input("Input number one"))
number2 = int(input("Now number two"))
number3 = (number1) - (number2)
print(number3)
^ Example of working code
>>224558
Okay so the addition is working but how to get subtraction too, like how to get a program in which people can choose "+" or "-" and input the 2 numbers
number1 = int(input("Input number one"))
number2 = int(input("Now number two"))
addOrSubtract = input("Do you wish to add or subtract?")
if addOrSubtract == "add":
number3 = (number1) + (number2)
else:
number3 = (number1) - (number2)
print(number3)
If you want me to explain it, I can attach images with comments!
Remember to press tab before number3 on both lines in the if statement to make an indent.
I have work right now so sorry I can't right now, if you have the time then add my steam @Zer0Ctrl, level 28 or something - else isn't invalid, you must have not indented it properly, make sure it's in line with the if statement and the two lines beginning with number3 are 4 spaces away from that. Add me on steam and ill get back to you asap!
>>224572
thank yoU!!!!
Hey, same guy, you didnt add me?