Skip to content Skip to sidebar Skip to footer

How To Add And Subtract In Python

So I am making a statcalc and everything is working except adding. When I select the option to add it just skips it and says select an option. I was wondering what's wrong with it?

Solution 1:

You need to turn your input strings into ints. Like this:

number_1 = int(raw_input("What is the first number you want to add? "))
number_2 = int(raw_input("What do you want to add to it? "))
sum = number_1 + number_2
printsum

Solution 2:

In Python 2, input would eval the typed text and return an integer, whereas under Python 3 input just returns a string containing the typed text (equivalent to raw_input in Python 2).

See this link for other changes between Python version 2.x & 3.x

http://docs.python.org/dev/whatsnew/3.0.html

Solution 3:

print("Welcome to fizz buzz")
num1=input("Choose a number from 1 to 100")
if num1 is >= 50:
 print("hello")
else:
 print("good bye")

Solution 4:

Sample Input 0

2

1 3

10 100

Sample Output 0

-2

-90

Given a two integers print the difference of two integers.

*Hint: Try to implement without using '-' operator.

Post a Comment for "How To Add And Subtract In Python"